公屏:修复新消息按钮和甩动动画问题
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user