【发布时间】:2011-07-13 17:56:34
【问题描述】:
这只是一个测试,我可能会将它添加到应用程序中。嗯....我有一个tableView。
如果点击
button1,我希望tableView自动向上滚动到顶部。如果我点击
button2,我希望tableView 自动向下滚动到底部。
如何做到这一点?滚动速度呢?
【问题讨论】:
标签: iphone objective-c cocoa-touch uitableview scroll
这只是一个测试,我可能会将它添加到应用程序中。嗯....我有一个tableView。
如果点击button1,我希望tableView自动向上滚动到顶部。
如果我点击button2,我希望tableView 自动向下滚动到底部。
如何做到这一点?滚动速度呢?
【问题讨论】:
标签: iphone objective-c cocoa-touch uitableview scroll
你也可以看看滚动视图的setContentOffset:animated:方法。
登顶意味着,
[self.tableView setContentOffset:CGPointZero animated:YES];
底部是,
CGFloat height = self.tableView.contentSize.height - self.tableView.bounds.size.height;
[self.tableView setContentOffset:CGPointMake(0, height) animated:YES];
您无法控制动画持续时间。
scrollToRowAtIndexPath:atScrollPosition:animated: 的唯一问题是在设置部分和表格标题时它可能没有帮助。
【讨论】:
scrollToRowAtIndexPath:atScrollPosition:animated:
滚动接收器,直到由索引路径标识的行位于屏幕上的特定位置。
- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated
【讨论】: