iOS 【IM 如何push到聊天界面后及时刷新到底部】

来源:互联网 发布:泰牛程序员学费多少 编辑:程序博客网 时间:2024/06/14 09:12

在我们做即时通讯的时候,如何在进入聊天界面的时候刷新到最后一行?,类似如下图:


网上有提供很多的方法,但尝试过后发现不是很清晰。现提供方法如下:

- (void)viewDidAppear:(BOOL)animated {    if (self.chat_Arr.count>0) {        [_chat_Tabv scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:self.chat_Arr.count - 1 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];    }}

需要注意的是,一定要在 viewDidAppear 中去调用,也就是在初始化完成之后。且不要在 viewWilAppear 中去做,因为不会调用。

2 0