iOS UITableView滚动到本节底部 [英] iOS UITableView Scroll to bottom of section
本文介绍了iOS UITableView滚动到本节底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要创建一个包含2个部分的表格视图.我可以通过编程方式将单元格添加到每个部分,并且在添加时使用
I am going to make a tableview with 2 sections inside it. I can add cells to every section programmatically and when i add, i scroll to the end of tableview using
[_tableView setContentOffset:CGPointMake(0, CGFLOAT_MAX)];
我的问题是我如何滚动到第0节的末尾,以便当用户将单元格添加到第0节时,tableview动态滚动到第0节的最后一个单元格.
My question is how can i scroll to the end of the section 0, so that when user add a cell to section 0, tableview scroll dynamically to the last cell in section 0.
谢谢.
推荐答案
您可以尝试使用以下代码:
You can try with this code:
int yourSection = 2;
int lastRow = [tableView numberOfRowsInSection:yourSection] - 1;
[tableView scrollToRowAtIndexPath:[NSIndexPath lastRow inSection:yourSection] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
您将获得本节中的行数,然后滚动到该indexPath.
You get the numbers of rows in your section, then scroll to that indexPath.
这篇关于iOS UITableView滚动到本节底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文