|
@@ -23,6 +23,52 @@
|
|
|
|
|
|
@implementation KSChatListViewController
|
|
|
|
|
|
+- (void)refreshChatListMessage {
|
|
|
+ NSArray *visiableIndexArray = self.conversationListTableView.indexPathsForVisibleRows;
|
|
|
+ if (visiableIndexArray.count) {
|
|
|
+ NSIndexPath *firstIndexPath = [visiableIndexArray firstObject];
|
|
|
+
|
|
|
+ NSInteger firstIndex = firstIndexPath.row;
|
|
|
+ if ([self isAtTheBottomOfTableView]) {
|
|
|
+ NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
|
|
|
+ [self.conversationListTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ for (NSInteger index = firstIndex+1; index < self.conversationListDataSource.count; index++) {
|
|
|
+ RCConversationModel *model = self.conversationListDataSource[index];
|
|
|
+ if (model.unreadMessageCount > 0) {
|
|
|
+ NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
|
|
|
+ [self.conversationListTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (index == self.conversationListDataSource.count - 1) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 判断消息是否在collectionView的底部
|
|
|
+ *
|
|
|
+ * @return 是否在底部
|
|
|
+ */
|
|
|
+- (BOOL)isAtTheBottomOfTableView {
|
|
|
+ if (self.conversationListTableView.contentSize.height <= self.conversationListTableView.frame.size.height) {
|
|
|
+ return YES;
|
|
|
+ }
|
|
|
+ CGFloat height = self.conversationListTableView.frame.size.height;
|
|
|
+ CGFloat contentOffsetY = self.conversationListTableView.contentOffset.y;
|
|
|
+ CGFloat bottomOffset = self.conversationListTableView.contentSize.height - contentOffsetY;
|
|
|
+ if (bottomOffset <= height) {
|
|
|
+ return YES;
|
|
|
+ }else{
|
|
|
+ return NO;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
- (instancetype)init {
|
|
|
self = [super init];
|
|
|
if (self) {
|
|
@@ -44,11 +90,7 @@
|
|
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
|
[super viewWillAppear:animated];
|
|
|
- if (self.isSubList == NO) {
|
|
|
- self.conversationListTableView.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight - kTabBarHeight);
|
|
|
- }
|
|
|
- else {
|
|
|
- self.conversationListTableView.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);
|
|
|
+ if (self.isSubList) {
|
|
|
[self allocLeftButton];
|
|
|
self.conversationListTableView.tableHeaderView = [UIView new];
|
|
|
}
|