如何在添加新项目时自动滚动tableview?如何在添加新项目时自动滚动tableview?
我TRED使用
- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath
atScrollPosition:(UITableViewScrollPosition)scrollPosition
animated:(BOOL)animated
但我无法弄清楚。
您能否提供样本代码?
如何在添加新项目时自动滚动tableview?如何在添加新项目时自动滚动tableview?
我TRED使用
- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath
atScrollPosition:(UITableViewScrollPosition)scrollPosition
animated:(BOOL)animated
但我无法弄清楚。
您能否提供样本代码?
为了更好的指导,你应该可以看到文档的[UITableView scrollToRowAtIndexPath:atScrollPosition:animated:]
下面是即时解决....
int row = [dataController count] - 1;
int section = 0;
NSIndexPath *scrollIndexPath = [NSIndexPath indexPathForRow:row inSection:section];
[[self tableView] scrollToRowAtIndexPath:scrollIndexPath
atScrollPosition:UITableViewScrollPositionBottom
animated:YES];
这条线从那里你想要滚动tableview中添加到您的代码。
[myTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:[_databaseArray count]-1 inSection:0]
atScrollPosition:UITableViewScrollPositionBottom
animated:YES];
请给你的答案添加一些描述,让我们凡人了解你提供的解决方案。 – Rachcha
非常感谢您的帮助。它现在好了:) – sajaz