【发布时间】:2010-05-25 15:39:10
【问题描述】:
我想在单击按钮时向下滚动 UITableView 2 单元格。向下移动的总高度为 100px。我怎样才能做到这一点?
【问题讨论】:
标签: iphone objective-c cocoa-touch uitableview
我想在单击按钮时向下滚动 UITableView 2 单元格。向下移动的总高度为 100px。我怎样才能做到这一点?
【问题讨论】:
标签: iphone objective-c cocoa-touch uitableview
设置contentOffset 属性。
[aTableview setContentOffset:CGPointMake(0,100)];
【讨论】:
self.tableView.setContentOffset(CGPoint(x: 0, y: 20 ), animated: true)
如果您知道要滚动哪个单元格以使用 scrollToRowAtIndexPath:atScrollPosition:animated:
否则使用 contentOffset 属性或滚动像素http://developer.apple.com/IPhone/library/documentation/UIKit/Reference/UIScrollView_Class/Reference/UIScrollView.html#//apple_ref/doc/uid/TP40006922-CH3-SW26
【讨论】:
swift 3 版本的答案:
tableView.setContentOffset(CGPoint(x: 0,y :100), animated: false)
【讨论】: