#iOS问题记录#UITableView加载后直接滑动倒最底部

类似QQ的聊天框,当进入聊天框,直接滑动倒最底部;

需要先将以他变了view滚动倒底部,再来移动NSIndexPath,

代码如下:

-(void) doForceScrollToBottom
{    
    dispatch_async(dispatch_get_main_queue(), ^
                   {
                      if(  self.mTableViewConsult.contentSize.height - self.mTableViewConsult.contentOffset.y > self.mTableViewConsult.frame.size.height )
                       {
                          [self.mTableViewConsult setContentOffset:CGPointMake(0, self.mTableViewConsult.contentSize.height - self.mTableViewConsult.frame.size.height)];
                       }
                      
                      usleep(5000);
                      
                      NSIndexPath* path = [NSIndexPath indexPathForRow: nMaxTableCount - 1 inSection:0];
                      if( path )
                       {
                          [self.mTableViewConsult scrollToRowAtIndexPath:path atScrollPosition:UITableViewScrollPositionBottom animated:NO];
                       }
                });
}
原文地址:https://www.cnblogs.com/Sanje3000/p/6718507.html