self.scrollView.pagingEnabled = YES; - (void)nextImage { // 1.增加pageControl的页码 int page = 0; if (self.pageControl.currentPage == MJImageCount - 1) { page = 0; } else { page = self.pageControl.currentPage + 1; } // 2.计算scrollView滚动的位置 CGFloat offsetX = page * self.scrollView.frame.size.width; CGPoint offset = CGPointMake(offsetX, 0); [self.scrollView setContentOffset:offset animated:YES]; } #pragma mark - 代理方法 /** * 当scrollView正在滚动就会调用 */ - (void)scrollViewDidScroll:(UIScrollView *)scrollView { // 根据scrollView的滚动位置决定pageControl显示第几页 CGFloat scrollW = scrollView.frame.size.width; int page = (scrollView.contentOffset.x + scrollW * 0.5) / scrollW; self.pageControl.currentPage = page; }