公屏:更多消息按钮和消息追加逻辑调整
This commit is contained in:
@@ -60,7 +60,8 @@
|
||||
#pragma mark - Response
|
||||
- (void)messageTipsBtnAction:(UIButton *)sender {
|
||||
self.isPending = NO;
|
||||
[self tryToAppendAndScrollToBottom];
|
||||
self.messageTipsBtn.hidden = YES;
|
||||
[self appendAndScrollToBottom];
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
@@ -96,27 +97,11 @@
|
||||
///添加信息
|
||||
- (void)addRoomMessage:(NIMMessage *)message {
|
||||
[self.incomingMessages addObject:message];
|
||||
///开始加入数据
|
||||
[self tryToAppendAndScrollToBottom];
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加数据并滚动到底部。
|
||||
* 目前的逻辑下,self.isPending 和 self.incomingMessages 变化之后,都必须调用该方法:
|
||||
* 因为要同步管理 self.messageTipsBtn 和 self.messageTableView 的状态更新。
|
||||
*/
|
||||
- (void)tryToAppendAndScrollToBottom {
|
||||
// 处于爬楼状态更新更多按钮
|
||||
if (self.isPending && self.incomingMessages.count > 0) {
|
||||
if (self.isPending) {
|
||||
self.messageTipsBtn.hidden = NO;
|
||||
} else {
|
||||
self.messageTipsBtn.hidden = YES;
|
||||
[self appendAndScrollToBottom];
|
||||
}
|
||||
|
||||
if (!self.isPending) {
|
||||
// 如果不处在爬楼状态,追加数据源并滚动到底部
|
||||
[self appendAndScrollToBottom];
|
||||
}
|
||||
}
|
||||
|
||||
///追加数据源
|
||||
@@ -236,14 +221,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
/** 手动拖拽动作彻底完成(减速到零) */
|
||||
/**
|
||||
手动拖拽动作彻底完成(减速到零)
|
||||
*/
|
||||
- (void)finishDraggingWith:(UIScrollView *)scrollView {
|
||||
CGFloat contentSizeH = scrollView.contentSize.height;
|
||||
CGFloat contentOffsetY = scrollView.contentOffset.y;
|
||||
CGFloat sizeH = scrollView.frame.size.height;
|
||||
self.isPending = contentSizeH - contentOffsetY - sizeH > 20.0;
|
||||
// 如果不处在爬楼状态,追加数据源并滚动到底部
|
||||
[self tryToAppendAndScrollToBottom];
|
||||
if (!self.isPending) {
|
||||
self.messageTipsBtn.hidden = YES;
|
||||
if (self.incomingMessages.count > 0) {
|
||||
[self appendAndScrollToBottom];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user