之前用的
[self.conversationMessageCollectionView scrollToBottomAnimated:NO];
这个有问题,消息不满一页的时候会把列表整体往下拉,要换成下面这种
NSUInteger finalRow = MAX(0, [self.conversationMessageCollectionView numberOfItemsInSection:0] - 1);
if (0 == finalRow) {
return;
}
NSIndexPath *finalIndexPath = [NSIndexPath indexPathForItem:finalRow inSection:0];
[self.conversationMessageCollectionView scrollToItemAtIndexPath:finalIndexPath atScrollPosition:UICollectionViewScrollPositionBottom animated:NO];
网友评论