项目中遇到的问题是UITableView 在viewWillAppear 中调用scroll to top 但是实际未执行。原因是scroll to top 是父类UIScrollView的接口 调用这个。。。然并卵
UITableView scroll 相关的API
- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated;//指定scroll 到某一行
- (void)scrollToNearestSelectedRowAtScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated;
UIScrollView scroll 相关的API
// When the user taps the status bar, the scroll view beneath the touch which is closest to the status bar will be scrolled to top, but only if its `scrollsToTop` property is YES, its delegate does not return NO from `-scrollViewShouldScrollToTop:`, and it is not already at the top.
// On iPhone, we execute this gesture only if there's one on-screen scroll view with `scrollsToTop` == YES. If more than one is found, none will be scrolled.
@property(nonatomic) BOOL scrollsToTop __TVOS_PROHIBITED; // default is YES.
[self.tableView setScrollsToTop:YES];//其实是父类UIScrollView的接口 调用这个。。。然并卵
if (self.arrayData.count) {
NSIndexPath *indexpath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView scrollToRowAtIndexPath:indexpath atScrollPosition:UITableViewScrollPositionTop animated:YES];//指定scroll 到某一行
}
网友评论