diff --git a/keyBoard.xcodeproj/project.pbxproj b/keyBoard.xcodeproj/project.pbxproj index 41bd2b8..361bae5 100644 --- a/keyBoard.xcodeproj/project.pbxproj +++ b/keyBoard.xcodeproj/project.pbxproj @@ -245,6 +245,7 @@ 04F4C0B62F33053800E8F08C /* KBSvipSubscribeCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 04F4C0B42F33053800E8F08C /* KBSvipSubscribeCell.m */; }; 04F4C0BB2F3306CF00E8F08C /* KBSvipFlowLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 04F4C0BA2F3306CF00E8F08C /* KBSvipFlowLayout.m */; }; 04F4C0BC2F3306CF00E8F08C /* KBSvipBenefitBgView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04F4C0B82F3306CF00E8F08C /* KBSvipBenefitBgView.m */; }; + 04F4C0BF2F33369900E8F08C /* KBAIChatDeleteConfirmView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04F4C0BE2F33369900E8F08C /* KBAIChatDeleteConfirmView.m */; }; 04FC95672EB0546C007BD342 /* KBKey.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FC95652EB0546C007BD342 /* KBKey.m */; }; 04FC956A2EB05497007BD342 /* KBKeyButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FC95692EB05497007BD342 /* KBKeyButton.m */; }; 04FC956D2EB054B7007BD342 /* KBKeyboardView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FC956C2EB054B7007BD342 /* KBKeyboardView.m */; }; @@ -751,6 +752,8 @@ 04F4C0B82F3306CF00E8F08C /* KBSvipBenefitBgView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBSvipBenefitBgView.m; sourceTree = ""; }; 04F4C0B92F3306CF00E8F08C /* KBSvipFlowLayout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBSvipFlowLayout.h; sourceTree = ""; }; 04F4C0BA2F3306CF00E8F08C /* KBSvipFlowLayout.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBSvipFlowLayout.m; sourceTree = ""; }; + 04F4C0BD2F33369900E8F08C /* KBAIChatDeleteConfirmView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBAIChatDeleteConfirmView.h; sourceTree = ""; }; + 04F4C0BE2F33369900E8F08C /* KBAIChatDeleteConfirmView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBAIChatDeleteConfirmView.m; sourceTree = ""; }; 04FC953A2EAFAE56007BD342 /* KeyBoardPrefixHeader.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KeyBoardPrefixHeader.pch; sourceTree = ""; }; 04FC95642EB0546C007BD342 /* KBKey.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBKey.h; sourceTree = ""; }; 04FC95652EB0546C007BD342 /* KBKey.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBKey.m; sourceTree = ""; }; @@ -1489,6 +1492,8 @@ 048FFD232F28A836005D62AE /* KBChatLimitPopView.m */, 0F2A10112F3C0002002CA5A0 /* KBAIPersonaSidebarView.h */, 0F2A10122F3C0002002CA5A0 /* KBAIPersonaSidebarView.m */, + 04F4C0BD2F33369900E8F08C /* KBAIChatDeleteConfirmView.h */, + 04F4C0BE2F33369900E8F08C /* KBAIChatDeleteConfirmView.m */, ); path = PopView; sourceTree = ""; @@ -2488,6 +2493,7 @@ 046086CC2F1A092500757C95 /* KBAIReplyModel.m in Sources */, 046086CD2F1A092500757C95 /* KBAICommentModel.m in Sources */, 04791F8F2ED469C0004E8522 /* KBHostAppLauncher.m in Sources */, + 04F4C0BF2F33369900E8F08C /* KBAIChatDeleteConfirmView.m in Sources */, 047C65582EBCC06D0035E841 /* HomeRankCardCell.m in Sources */, 04D1F6B32EDFF10A00B12345 /* KBSkinInstallBridge.m in Sources */, 04122F912EC73AF700EF7AB3 /* KBVipPay.m in Sources */, diff --git a/keyBoard/Class/AiTalk/V/Comment/KBAICommentInputView.m b/keyBoard/Class/AiTalk/V/Comment/KBAICommentInputView.m index 757b74a..7898aad 100644 --- a/keyBoard/Class/AiTalk/V/Comment/KBAICommentInputView.m +++ b/keyBoard/Class/AiTalk/V/Comment/KBAICommentInputView.m @@ -99,8 +99,12 @@ - (void)sendButtonTapped { NSString *text = self.textField.text; - if (text.length > 0 && self.onSend) { - self.onSend(text); + if (text.length > 0) { + if (self.onSend) { + self.onSend(text); + } + // 点击发送后清空输入 + [self clearText]; } } diff --git a/keyBoard/Class/AiTalk/V/PopView/KBAIChatDeleteConfirmView.h b/keyBoard/Class/AiTalk/V/PopView/KBAIChatDeleteConfirmView.h new file mode 100644 index 0000000..a895e6d --- /dev/null +++ b/keyBoard/Class/AiTalk/V/PopView/KBAIChatDeleteConfirmView.h @@ -0,0 +1,27 @@ +// +// KBAIChatDeleteConfirmView.h +// keyBoard +// +// Created by Codex on 2026/02/03. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@class KBAIChatDeleteConfirmView; + +@protocol KBAIChatDeleteConfirmViewDelegate + +- (void)chatDeleteConfirmViewDidTapDelete:(KBAIChatDeleteConfirmView *)view; +- (void)chatDeleteConfirmViewDidTapCancel:(KBAIChatDeleteConfirmView *)view; + +@end + +@interface KBAIChatDeleteConfirmView : UIView + +@property (nonatomic, weak) id delegate; + +@end + +NS_ASSUME_NONNULL_END diff --git a/keyBoard/Class/AiTalk/V/PopView/KBAIChatDeleteConfirmView.m b/keyBoard/Class/AiTalk/V/PopView/KBAIChatDeleteConfirmView.m new file mode 100644 index 0000000..03c0ea3 --- /dev/null +++ b/keyBoard/Class/AiTalk/V/PopView/KBAIChatDeleteConfirmView.m @@ -0,0 +1,172 @@ +// +// KBAIChatDeleteConfirmView.m +// keyBoard +// +// Created by Codex on 2026/02/03. +// + +#import "KBAIChatDeleteConfirmView.h" +#import + +@interface KBAIChatDeleteConfirmView () + + +@property (nonatomic, strong) UIView *coverView; + +@property (nonatomic, strong) UIImageView *iconView; +@property (nonatomic, strong) UILabel *titleLabel; +@property (nonatomic, strong) UILabel *messageLabel; +@property (nonatomic, strong) UIButton *deleteButton; +@property (nonatomic, strong) UIButton *cancelButton; + +@end + +@implementation KBAIChatDeleteConfirmView + +- (instancetype)initWithFrame:(CGRect)frame { + if (self = [super initWithFrame:frame]) { + self.backgroundColor = [UIColor clearColor]; + self.layer.cornerRadius = 16.0; + self.layer.masksToBounds = YES; + [self setupUI]; + } + return self; +} + +#pragma mark - UI + +- (void)setupUI { + [self addSubview:self.coverView]; + [self addSubview:self.iconView]; + [self.coverView addSubview:self.titleLabel]; + [self.coverView addSubview:self.messageLabel]; + [self.coverView addSubview:self.deleteButton]; + [self.coverView addSubview:self.cancelButton]; + + + [self.coverView mas_makeConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(216); + make.bottom.left.right.bottom.equalTo(self); + }]; + + [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.equalTo(self).offset(5); + make.centerX.equalTo(self); + make.width.height.mas_equalTo(64); + }]; + + + + [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.equalTo(self.coverView).offset(50); + make.left.equalTo(self.coverView).offset(16); + make.right.equalTo(self.coverView).offset(-16); + }]; + + [self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.equalTo(self.titleLabel.mas_bottom).offset(16); + make.left.equalTo(self.coverView).offset(20); + make.right.equalTo(self.coverView).offset(-20); + }]; + + [self.deleteButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.equalTo(self.coverView).offset(24); + make.bottom.equalTo(self.coverView).offset(-20); + make.height.mas_equalTo(40); + make.right.equalTo(self.coverView.mas_centerX).offset(-15); + }]; + + [self.cancelButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.right.equalTo(self.coverView).offset(-24); + make.bottom.equalTo(self.coverView).offset(-20); + make.height.mas_equalTo(40); + make.left.equalTo(self.coverView.mas_centerX).offset(15); + }]; +} + +#pragma mark - Actions + +- (void)onTapDelete { + if ([self.delegate respondsToSelector:@selector(chatDeleteConfirmViewDidTapDelete:)]) { + [self.delegate chatDeleteConfirmViewDidTapDelete:self]; + } +} + +- (void)onTapCancel { + if ([self.delegate respondsToSelector:@selector(chatDeleteConfirmViewDidTapCancel:)]) { + [self.delegate chatDeleteConfirmViewDidTapCancel:self]; + } +} + +#pragma mark - Lazy + +- (UIImageView *)iconView { + if (!_iconView) { + _iconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"chat_del_icon"]]; + _iconView.contentMode = UIViewContentModeScaleAspectFit; + } + return _iconView; +} + +- (UILabel *)titleLabel { + if (!_titleLabel) { + _titleLabel = [[UILabel alloc] init]; + _titleLabel.text = KBLocalized(@"Are you sure to delete?"); + _titleLabel.font = [UIFont boldSystemFontOfSize:18]; + _titleLabel.textColor = [UIColor colorWithWhite:0.1 alpha:1.0]; + _titleLabel.textAlignment = NSTextAlignmentCenter; + } + return _titleLabel; +} + +- (UILabel *)messageLabel { + if (!_messageLabel) { + _messageLabel = [[UILabel alloc] init]; + _messageLabel.text = KBLocalized(@"The existing conversation history will be cleared."); + _messageLabel.font = [UIFont systemFontOfSize:14]; + _messageLabel.textColor = [UIColor colorWithWhite:0.45 alpha:1.0]; + _messageLabel.textAlignment = NSTextAlignmentCenter; + _messageLabel.numberOfLines = 0; + } + return _messageLabel; +} + +- (UIButton *)deleteButton { + if (!_deleteButton) { + _deleteButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_deleteButton setTitle:KBLocalized(@"Delete") forState:UIControlStateNormal]; + [_deleteButton setTitleColor:[UIColor colorWithWhite:0.2 alpha:1.0] forState:UIControlStateNormal]; + _deleteButton.titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightSemibold]; + _deleteButton.backgroundColor = [UIColor colorWithWhite:0.93 alpha:1.0]; + _deleteButton.layer.cornerRadius = 20; + _deleteButton.layer.masksToBounds = YES; + [_deleteButton addTarget:self action:@selector(onTapDelete) forControlEvents:UIControlEventTouchUpInside]; + } + return _deleteButton; +} + +- (UIButton *)cancelButton { + if (!_cancelButton) { + _cancelButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_cancelButton setTitle:KBLocalized(@"Think Again") forState:UIControlStateNormal]; + [_cancelButton setTitleColor:[UIColor colorWithWhite:0.15 alpha:1.0] forState:UIControlStateNormal]; + _cancelButton.titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightSemibold]; + _cancelButton.backgroundColor = [UIColor colorWithRed:0.80 green:0.94 blue:0.72 alpha:1.0]; + _cancelButton.layer.cornerRadius = 20; + _cancelButton.layer.masksToBounds = YES; + [_cancelButton addTarget:self action:@selector(onTapCancel) forControlEvents:UIControlEventTouchUpInside]; + } + return _cancelButton; +} + + +- (UIView *)coverView{ + if (!_coverView) { + _coverView = [[UIView alloc] init]; + _coverView.backgroundColor = [UIColor whiteColor]; + _coverView.layer.cornerRadius = 30; + _coverView.layer.masksToBounds = true; + } + return _coverView; +} +@end diff --git a/keyBoard/Class/AiTalk/VC/KBAIMessageChatingVC.m b/keyBoard/Class/AiTalk/VC/KBAIMessageChatingVC.m index d2d39a5..f44264d 100644 --- a/keyBoard/Class/AiTalk/VC/KBAIMessageChatingVC.m +++ b/keyBoard/Class/AiTalk/VC/KBAIMessageChatingVC.m @@ -10,12 +10,14 @@ #import "KBChattedCompanionModel.h" #import "KBHUD.h" #import "KBAIChatMessageCacheManager.h" +#import "KBAIChatDeleteConfirmView.h" +#import "LSTPopView.h" #import /// 聊天会话被重置的通知 static NSString * const KBChatSessionDidResetNotification = @"KBChatSessionDidResetNotification"; -@interface KBAIMessageChatingVC () +@interface KBAIMessageChatingVC () @property (nonatomic, strong) AiVM *viewModel; @property (nonatomic, strong) NSMutableArray *chattedList; @@ -24,6 +26,16 @@ static NSString * const KBChatSessionDidResetNotification = @"KBChatSessionDidRe @property (nonatomic, strong) UIButton *deleteButton; /// 当前长按的 indexPath @property (nonatomic, strong) NSIndexPath *longPressIndexPath; +/// 长按手势 +@property (nonatomic, strong) UILongPressGestureRecognizer *longPressGesture; +/// 单击手势(用于隐藏删除按钮) +@property (nonatomic, strong) UITapGestureRecognizer *tapGesture; +/// 删除按钮显示代数(用于避免旧的隐藏动画 completion 误删新按钮) +@property (nonatomic, assign) NSInteger deleteButtonGeneration; +/// 待删除的 indexPath(弹窗确认使用) +@property (nonatomic, strong) NSIndexPath *pendingDeleteIndexPath; +/// 删除确认弹窗 +@property (nonatomic, weak) LSTPopView *deleteConfirmPopView; @end @@ -39,23 +51,53 @@ static NSString * const KBChatSessionDidResetNotification = @"KBChatSessionDidRe [self setupLongPressGesture]; // 添加点击手势,用于隐藏删除按钮 - UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)]; - tapGesture.cancelsTouchesInView = NO; // 不影响 cell 的点击 - [self.tableView addGestureRecognizer:tapGesture]; + self.tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)]; + self.tapGesture.cancelsTouchesInView = NO; // 不影响 cell 的点击 + self.tapGesture.delegate = self; + if (self.longPressGesture) { + [self.tapGesture requireGestureRecognizerToFail:self.longPressGesture]; + } + [self.tableView addGestureRecognizer:self.tapGesture]; +} + +#pragma mark - UIGestureRecognizerDelegate + +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { + // 删除按钮显示时,点击按钮本身不走 tableView 的 tap 逻辑 + if (gestureRecognizer == self.tapGesture) { + if (self.deleteButton && !self.deleteButton.hidden) { + CGPoint p = [touch locationInView:self.deleteButton]; + if (CGRectContainsPoint(self.deleteButton.bounds, p)) { + return NO; + } + } + } + return YES; } #pragma mark - 手势处理 - (void)setupLongPressGesture { - UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)]; - longPress.minimumPressDuration = 0.5; // 长按0.5秒 - [self.tableView addGestureRecognizer:longPress]; + self.longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)]; + self.longPressGesture.minimumPressDuration = 0.5; // 长按0.5秒 + self.longPressGesture.delegate = self; + [self.tableView addGestureRecognizer:self.longPressGesture]; } - (void)handleLongPress:(UILongPressGestureRecognizer *)gesture { + CGPoint point = [gesture locationInView:self.tableView]; + NSLog(@"[KBAIMessageChatingVC] longPress state=%ld point=(%.1f, %.1f)", + (long)gesture.state, point.x, point.y); + if (gesture.state == UIGestureRecognizerStateBegan) { - CGPoint point = [gesture locationInView:self.tableView]; + // 关键:长按期间禁用 tap,避免同一轮触摸结束被识别为 tap 导致“闪一下就隐藏” + if (self.tapGesture.enabled) { + self.tapGesture.enabled = NO; + NSLog(@"[KBAIMessageChatingVC] tapGesture disabled for longPress"); + } NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:point]; + NSLog(@"[KBAIMessageChatingVC] longPress began indexPath=%@", + indexPath); if (indexPath) { // 在手指位置显示删除按钮 @@ -64,12 +106,23 @@ static NSString * const KBChatSessionDidResetNotification = @"KBChatSessionDidRe // 在 showDeleteButtonAtPoint 之后再设置,避免被 hideDeleteButton 清空 self.longPressIndexPath = indexPath; } + } else if (gesture.state == UIGestureRecognizerStateEnded || + gesture.state == UIGestureRecognizerStateCancelled || + gesture.state == UIGestureRecognizerStateFailed) { + if (!self.tapGesture.enabled) { + self.tapGesture.enabled = YES; + NSLog(@"[KBAIMessageChatingVC] tapGesture re-enabled after longPress"); + } } } - (void)handleTapGesture:(UITapGestureRecognizer *)gesture { // 点击其他地方隐藏删除按钮 if (self.deleteButton && !self.deleteButton.hidden) { + CGPoint pointInView = [gesture locationInView:self.tableView]; + NSLog(@"[KBAIMessageChatingVC] tap state=%ld point=(%.1f, %.1f)", + (long)gesture.state, pointInView.x, pointInView.y); + CGPoint pointInButton = [gesture locationInView:self.deleteButton]; // 如果点击的不是删除按钮,则隐藏 @@ -83,8 +136,10 @@ static NSString * const KBChatSessionDidResetNotification = @"KBChatSessionDidRe } - (void)showDeleteButtonAtPoint:(CGPoint)point { - // 隐藏之前的按钮 - [self hideDeleteButton]; + // 新一轮展示:使之前的隐藏动画 completion 失效 + self.deleteButtonGeneration += 1; + NSLog(@"[KBAIMessageChatingVC] showDeleteButtonAtPoint=(%.1f, %.1f) generation=%ld", + point.x, point.y, (long)self.deleteButtonGeneration); // 创建删除按钮 if (!self.deleteButton) { @@ -105,7 +160,14 @@ static NSString * const KBChatSessionDidResetNotification = @"KBChatSessionDidRe } // 添加到父视图(确保在最上层) - [self.view addSubview:self.deleteButton]; + if (self.deleteButton.superview != self.view) { + [self.view addSubview:self.deleteButton]; + } else { + [self.view bringSubviewToFront:self.deleteButton]; + } + + // 取消隐藏动画,避免闪一下 + [self.deleteButton.layer removeAllAnimations]; // 设置按钮大小和位置 CGSize buttonSize = CGSizeMake(110, 40); @@ -138,6 +200,9 @@ static NSString * const KBChatSessionDidResetNotification = @"KBChatSessionDidRe }]; self.deleteButton.hidden = NO; + self.deleteButton.alpha = 1.0; + self.deleteButton.transform = CGAffineTransformIdentity; + NSLog(@"[KBAIMessageChatingVC] deleteButton shown"); // 添加弹出动画 self.deleteButton.transform = CGAffineTransformMakeScale(0.3, 0.3); @@ -150,10 +215,20 @@ static NSString * const KBChatSessionDidResetNotification = @"KBChatSessionDidRe - (void)hideDeleteButton { if (self.deleteButton) { + NSInteger generation = self.deleteButtonGeneration; + NSLog(@"[KBAIMessageChatingVC] hideDeleteButton generation=%ld", (long)generation); + // 取消之前的动画,避免叠加 + [self.deleteButton.layer removeAllAnimations]; [UIView animateWithDuration:0.15 animations:^{ self.deleteButton.alpha = 0; self.deleteButton.transform = CGAffineTransformMakeScale(0.8, 0.8); } completion:^(BOOL finished) { + // 如果期间又展示了新一轮按钮,则不执行移除(避免“闪一下”) + if (generation != self.deleteButtonGeneration) { + NSLog(@"[KBAIMessageChatingVC] hide completion ignored (generation changed: %ld -> %ld)", + (long)generation, (long)self.deleteButtonGeneration); + return; + } self.deleteButton.hidden = YES; [self.deleteButton removeFromSuperview]; }]; @@ -166,26 +241,69 @@ static NSString * const KBChatSessionDidResetNotification = @"KBChatSessionDidRe return; } - // 保存 indexPath,因为后面会清空 - NSIndexPath *indexPath = self.longPressIndexPath; + // 保存 indexPath,因为 hideDeleteButton 会清空 + self.pendingDeleteIndexPath = self.longPressIndexPath; + [self hideDeleteButton]; + [self showDeleteConfirmPopView]; +} + +#pragma mark - 删除确认弹窗 + +- (void)showDeleteConfirmPopView { + if (self.deleteConfirmPopView) { + [self.deleteConfirmPopView dismiss]; + } + + CGFloat width = KB_SCREEN_WIDTH - 80; + KBAIChatDeleteConfirmView *content = [[KBAIChatDeleteConfirmView alloc] initWithFrame:CGRectMake(0, 0, width, 260)]; + content.delegate = self; + + LSTPopView *popView = [LSTPopView initWithCustomView:content + parentView:nil + popStyle:LSTPopStyleFade + dismissStyle:LSTDismissStyleFade]; + popView.bgColor = [[UIColor blackColor] colorWithAlphaComponent:0.4]; + popView.hemStyle = LSTHemStyleCenter; + popView.isClickBgDismiss = YES; + popView.isAvoidKeyboard = NO; + self.deleteConfirmPopView = popView; + [popView pop]; +} + +#pragma mark - KBAIChatDeleteConfirmViewDelegate + +- (void)chatDeleteConfirmViewDidTapDelete:(KBAIChatDeleteConfirmView *)view { + [self.deleteConfirmPopView dismiss]; + NSIndexPath *indexPath = self.pendingDeleteIndexPath; + self.pendingDeleteIndexPath = nil; + [self performDeleteAtIndexPath:indexPath]; +} + +- (void)chatDeleteConfirmViewDidTapCancel:(KBAIChatDeleteConfirmView *)view { + [self.deleteConfirmPopView dismiss]; + self.pendingDeleteIndexPath = nil; +} + +#pragma mark - 删除逻辑 + +- (void)performDeleteAtIndexPath:(NSIndexPath *)indexPath { + if (!indexPath) { + return; + } // 获取要删除的数据 if (indexPath.row >= self.chattedList.count) { - NSLog(@"[KBAIMessageChatingVC] 错误:索引越界,row=%ld, count=%ld", + NSLog(@"[KBAIMessageChatingVC] 错误:索引越界,row=%ld, count=%ld", (long)indexPath.row, (long)self.chattedList.count); - [self hideDeleteButton]; return; } KBChattedCompanionModel *model = self.chattedList[indexPath.row]; NSInteger companionId = model.companionId; - NSLog(@"[KBAIMessageChatingVC] 开始删除聊天记录:companionId=%ld, name=%@", + NSLog(@"[KBAIMessageChatingVC] 开始删除聊天记录:companionId=%ld, name=%@", (long)companionId, model.name); - // 隐藏删除按钮 - [self hideDeleteButton]; - // 显示加载提示 [KBHUD show]; @@ -214,7 +332,7 @@ static NSString * const KBChatSessionDidResetNotification = @"KBChatSessionDidRe } // 2. 更新 TableView(带动画) - [weakSelf.tableView deleteRowsAtIndexPaths:@[indexPath] + [weakSelf.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationLeft]; // 3. ✅ 清除缓存管理器中的聊天记录(关键!)