Osc*_*ros 2 iphone objective-c ios
根据分页UIScrollView的页面更改,我正在调用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];
}
Run Code Online (Sandbox Code Playgroud)
但是,自动滚动的动画发生得太慢了.有没有办法让这个动画更加活泼?
dan*_*ata 17
快速解决方案可能是:
[UIView animateWithDuration:aSmallValue animations:^{
[self.tableView scrollToRowAtIndexPath:indexPath
atScrollPosition:UITableViewScrollPositionTop
animated:NO];
}];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5460 次 |
| 最近记录: |