美文网首页
tableView自动滚动到最后一行

tableView自动滚动到最后一行

作者: 飞扬你我 | 来源:发表于2019-03-25 16:39 被阅读0次

    NSInteger s = [self.tableView numberOfSections];  //有多少组

    if (s<1) return;  //无数据时不执行 要不会crash

    NSInteger r = [self.tableView numberOfRowsInSection:s-1]; //最后一组有多少行

    if(r<1)return;

    NSIndexPath *ip = [NSIndexPath indexPathForRow:r-1 inSection:s-1];  //取最后一行数据

    [self.tableView scrollToRowAtIndexPath:ip atScrollPosition:UITableViewScrollPositionBottom animated:animated]; //滚动到最后一行

相关文章

网友评论

      本文标题:tableView自动滚动到最后一行

      本文链接:https://www.haomeiwen.com/subject/xambsftx.html