公屏:修复新消息按钮和甩动动画问题

This commit is contained in:
zu
2021-11-05 19:30:41 +08:00
parent ee83ce3250
commit 4308392db2

View File

@@ -57,9 +57,9 @@
}
#pragma mark - Response
- (void)messagTipsBtnAction:(UIButton *)sender {
- (void)messageTipsBtnAction:(UIButton *)sender {
self.isPending = NO;
[self tryToAppendAndScrollToBottom];
self.isPending = NO;
}
#pragma mark - Private Method
@@ -99,7 +99,11 @@
[self tryToAppendAndScrollToBottom];
}
///
/**
*
* self.isPending self.incomingMessages
* self.messageTipsBtn self.messageTableView
*/
- (void)tryToAppendAndScrollToBottom {
//
if (self.isPending && self.incomingMessages.count > 0) {
@@ -132,9 +136,8 @@
[self.datasource addObject:[XPRoomMessageParser parseMessageAttribute:item]];
[indexPaths addObject:[NSIndexPath indexPathForRow:self.datasource.count - 1 inSection:0]];
}
NSLog(@"消息的总数%ld", self.datasource.count);
[self.incomingMessages removeAllObjects];
[self.messageTableView reloadData];
[self.incomingMessages removeAllObjects];
//
[self scrollToBottom:YES];
@@ -147,7 +150,7 @@
NSInteger r = [self.messageTableView numberOfRowsInSection:s-1]; //
if (r<1) return;
NSIndexPath *ip = [NSIndexPath indexPathForRow:r-1 inSection:s-1]; //
[self.messageTableView scrollToRowAtIndexPath:ip atScrollPosition:UITableViewScrollPositionNone animated:animated]; //
[self.messageTableView scrollToRowAtIndexPath:ip atScrollPosition:UITableViewScrollPositionBottom animated:animated]; //
}
#pragma mark - NIMChatManagerDelegate
@@ -197,6 +200,11 @@
//
[self finishDraggingWith:scrollView];
}
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
if (!self.isPending && self.incomingMessages.count <= 0) {
[self scrollToBottom:YES];
}
}
/** () */
- (void)finishDraggingWith:(UIScrollView *)scrollView {
@@ -264,7 +272,7 @@
_messageTipsBtn.layer.masksToBounds = YES;
_messageTipsBtn.titleLabel.font = [UIFont systemFontOfSize:12.0];
_messageTipsBtn.backgroundColor = [UIColor whiteColor];
[_messageTipsBtn addTarget:self action:@selector(messagTipsBtnAction:) forControlEvents:UIControlEventTouchUpInside];
[_messageTipsBtn addTarget:self action:@selector(messageTipsBtnAction:) forControlEvents:UIControlEventTouchUpInside];
_messageTipsBtn.hidden = YES;
}
return _messageTipsBtn;