|
@@ -16,6 +16,53 @@
|
|
|
|
|
|
@implementation KSConversationListController
|
|
|
|
|
|
+- (void)refreshChatListMessage {
|
|
|
+ NSArray *visiableIndexArray = self.tableViewForAll.indexPathsForVisibleRows;
|
|
|
+ if (visiableIndexArray.count) {
|
|
|
+ NSIndexPath *firstIndexPath = [visiableIndexArray firstObject];
|
|
|
+
|
|
|
+ NSInteger firstIndex = firstIndexPath.row;
|
|
|
+ if ([self isAtTheBottomOfTableView]) {
|
|
|
+ NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
|
|
|
+ [self.tableViewForAll scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ TUIConversationListBaseDataProvider *dataProvider = self.tableViewForAll.dataProvider;
|
|
|
+ NSMutableArray *conversationList = dataProvider.conversationList;
|
|
|
+ for (NSInteger index = firstIndex+1; index < conversationList.count; index++) {
|
|
|
+ TUIConversationCellData *model = conversationList[index];
|
|
|
+ if (model.isMarkAsUnread) {
|
|
|
+ NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
|
|
|
+ [self.tableViewForAll scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (index == conversationList.count - 1) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+/**
|
|
|
+ * 判断消息是否在collectionView的底部
|
|
|
+ *
|
|
|
+ * @return 是否在底部
|
|
|
+ */
|
|
|
+- (BOOL)isAtTheBottomOfTableView {
|
|
|
+ if (self.tableViewForAll.contentSize.height <= self.tableViewForAll.frame.size.height) {
|
|
|
+ return YES;
|
|
|
+ }
|
|
|
+ CGFloat height = self.tableViewForAll.frame.size.height;
|
|
|
+ CGFloat contentOffsetY = self.tableViewForAll.contentOffset.y;
|
|
|
+ CGFloat bottomOffset = self.tableViewForAll.contentSize.height - contentOffsetY;
|
|
|
+ if (bottomOffset <= height) {
|
|
|
+ return YES;
|
|
|
+ }else{
|
|
|
+ return NO;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
- (void)viewDidLoad {
|
|
|
[super viewDidLoad];
|
|
|
self.view.backgroundColor = [UIColor clearColor];
|