images = [[NSArray alloc] initWithObjects:@"w8.JPG",@"w7.JPG",@"w6.JPG",@"w5.JPG",@"w4.JPG",@"w3.JPG", @"w2.JPG", @"w1.JPG" ,@"w9.JPG", nil];
self.pageControl.hidden = NO;
[self.pageControl setNumberOfPages:9];
UISwipeGestureRecognizerDirection direction = [(UISwipeGestureRecognizer *) sender direction];
switch (direction) {
case UISwipeGestureRecognizerDirectionRight:
if (pageController != 0 && imageIndex != 9) {
[self.pageControl setCurrentPage:(pageController - 1)];
pageController --;
imageIndex++;
}
break;
case UISwipeGestureRecognizerDirectionLeft:
if (pageController <= 8 && pageController >= 0) {
[self.pageControl setCurrentPage:pageController];
pageController = pageController + 1;
imageIndex--;
}
break;
default:
break;
}
imageIndex = (imageIndex < 0) ? ([images count] - 1): imageIndex % [images count];
self.imageView.image = [UIImage imageNamed:[images objectAtIndex:imageIndex]];
当我开始向特定方向滑动时,例如左侧,page control's
点变化很好,但如果我改变方向,首先滑动点不会改变,我必须向相反方向滑动方向两次使点改变。我发现当您更改跟踪方向时,页面控件会再次计算当前点。
如何更改此默认设置?
答案 0 :(得分:0)
尝试将页面控件设置为静态变量,以便在向左右滑动时通过连续方法调用保留其值。 我希望有所帮助。