添加消息长按弹窗
This commit is contained in:
@@ -42,6 +42,7 @@ static const NSTimeInterval kTimestampInterval = 5 * 60; // 5 分钟
|
||||
@property (nonatomic, strong) UILabel *topStatusLabel;
|
||||
@property (nonatomic, assign) BOOL isTopLoading;
|
||||
@property (nonatomic, assign) BOOL isTopNoMore;
|
||||
@property (nonatomic, strong) UILongPressGestureRecognizer *messageLongPressGesture;
|
||||
|
||||
@end
|
||||
|
||||
@@ -101,6 +102,13 @@ static const NSTimeInterval kTimestampInterval = 5 * 60; // 5 分钟
|
||||
make.edges.equalTo(self);
|
||||
}];
|
||||
|
||||
// 长按消息操作
|
||||
self.messageLongPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self
|
||||
action:@selector(handleMessageLongPress:)];
|
||||
self.messageLongPressGesture.minimumPressDuration = 0.4;
|
||||
self.messageLongPressGesture.cancelsTouchesInView = YES;
|
||||
[self.tableView addGestureRecognizer:self.messageLongPressGesture];
|
||||
|
||||
// 初始化 contentInset
|
||||
self.contentBottomInset = 0;
|
||||
[self updateContentBottomInset:self.contentBottomInset];
|
||||
@@ -136,6 +144,32 @@ static const NSTimeInterval kTimestampInterval = 5 * 60; // 5 分钟
|
||||
*/
|
||||
}
|
||||
|
||||
#pragma mark - Long Press
|
||||
|
||||
- (void)handleMessageLongPress:(UILongPressGestureRecognizer *)gesture {
|
||||
if (gesture.state != UIGestureRecognizerStateBegan) {
|
||||
return;
|
||||
}
|
||||
|
||||
CGPoint point = [gesture locationInView:self.tableView];
|
||||
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:point];
|
||||
if (!indexPath || indexPath.row >= self.messages.count) {
|
||||
return;
|
||||
}
|
||||
|
||||
KBAiChatMessage *message = self.messages[indexPath.row];
|
||||
if (!message || message.isLoading || message.type == KBAiChatMessageTypeTime) {
|
||||
return;
|
||||
}
|
||||
|
||||
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
|
||||
CGRect cellRect = cell ? [cell convertRect:cell.bounds toView:nil] : CGRectZero;
|
||||
|
||||
if ([self.delegate respondsToSelector:@selector(chatTableView:didLongPressMessage:sourceRect:)]) {
|
||||
[self.delegate chatTableView:self didLongPressMessage:message sourceRect:cellRect];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Public Methods
|
||||
|
||||
- (void)setInverted:(BOOL)inverted {
|
||||
|
||||
Reference in New Issue
Block a user