如何在添加新项目时自动滚动tableview?

sma*_*nja 3 iphone objective-c uitableview ios4 ios

如何在添加新项目时自动滚动tableview?

我尝试使用

- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath 
              atScrollPosition:(UITableViewScrollPosition)scrollPosition 
                      animated:(BOOL)animated
Run Code Online (Sandbox Code Playgroud)

但我无法理解.

你能提供样品代码吗?

all*_*Nit 5

为了获得更好的指导,您应该看到[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];
Run Code Online (Sandbox Code Playgroud)