We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
有一个问题,就是ScrollView滑动比较快的时候,其CurrentPage的状态更新比较迟缓。
建考虑优化一下:
#pragma mark - ------------UIScrollView代理方方法------------ - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { // 不在这里设置currentPage --- 因为当滑动比较快速的时候,就出现currentPage更新比较慢 // [self.imagePageControl setCurrentPage:page]; // 这里就不用四舍五入了,因为在scroll滚动减速完成时才执行(相当于scroolView滚动静止的那一刻),四舍五入和不四舍五入,效果都一样 int img_count = (int)self.imageArray.count; int page = (int)(scrollView.contentOffset.x / scrollView.frame.size.width); if (self.imageArray && page == img_count - 1 && self.slideInto == NO) { [self buttonClick:nil]; } if (self.imageArray && page < img_count - 1 && self.slideInto == YES) { self.slideIntoNumber = 1; } if (self.imageArray && page == img_count - 1 && self.slideInto == YES) { UISwipeGestureRecognizer * swipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:nil action:nil]; if (swipeGestureRecognizer.direction == UISwipeGestureRecognizerDirectionRight) { self.slideIntoNumber++; if (self.slideIntoNumber == 3) { [self buttonClick:nil]; // [self handleSingleTapFrom]; } } } } // 这里也不能设置currentPage,状态无法及时更新 //- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView //{ // int page = (int)(scrollView.contentOffset.x / scrollView.frame.size.width); // [self.imagePageControl setCurrentPage:page]; //} // 2018-06-20 修改:新增一个代理方法,专门用来设置currentPage - (void)scrollViewDidScroll:(UIScrollView *)scrollView { // 四舍五入,保证pageControl状态跟随手指滑动刷新 [self.imagePageControl setCurrentPage:(int)((scrollView.contentOffset.x / scrollView.frame.size.width) + 0.5f)]; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
有一个问题,就是ScrollView滑动比较快的时候,其CurrentPage的状态更新比较迟缓。
建考虑优化一下:
The text was updated successfully, but these errors were encountered: