scrollToRowAtIndexPath:atScrollPosition:animation滚动太慢
基于分页的UIScrollView的页面更改,我调用了scrollToRowAtIndexPath:atScrollPosition:animated
根据显示的页面的表格scrollToRowAtIndexPath:atScrollPosition:animated
。
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{ CGFloat pageWidth = self.scrollView.frame.size.width; int page = floor((self.scrollView.contentOffset.x - pageWidth/2)/pageWidth)+1; self.pageControl.currentPage = page; NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:page]; [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES]; }
但是,自动滚动的animation发生得太慢了。 有没有办法让这个animation更加活泼?
一个快速解决scheme可能是:
[UIView animateWithDuration:aSmallValue animations:^{ [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:NO]; }];