5つのビューを含むスクロールビューがあり、ページコントロールの4番目のバブルをクリックすると2番目のビューに移動しますが、4番目のビューに直接移動する必要があります問題。次のようにpageControlのページコントロールを直接切り替える
呼び出しは次のとおりです。
- (void) pageTurn: (UIPageControl *) aPageControl
{
int whichPage = aPageControl.currentPage;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
scrollView.contentOffset = CGPointMake(320 * whichPage, 0);
[UIView commitAnimations];
}
と、次のように私のscrollViewDidScrollは次のとおりです:次のようにpageTurn方法の
[pageControl addTarget:self action:@selector(pageTurn:) forControlEvents:UIControlEventValueChanged];
実装です
- (void) scrollViewDidScroll: (UIScrollView *) aScrollView
{
CGPoint offset = aScrollView.contentOffset;
pageControl.currentPage = offset.x /320 ;
}
返信thnxと動作します –