Iphone 页面控制点没有改变

Iphone 页面控制点没有改变,iphone,ios,objective-c,uipagecontrol,Iphone,Ios,Objective C,Uipagecontrol,我正在尝试使用页面控件。这就是我所做的。我在情节提要中的视图中添加了一个 然后在我的ViewDidLoad images = [[NSMutableArray alloc]initWithObjects:[UIImage imageNamed:@"img1.jpg"],[UIImage imageNamed:@"img2.jpg"],[UIImage imageNamed:@"img3.jpg"],[UIImage imageNamed:@"img4.jpg"], nil]; pa

我正在尝试使用
页面控件
。这就是我所做的。我在<代码>情节提要中的视图中添加了一个

然后在我的
ViewDidLoad

   images = [[NSMutableArray alloc]initWithObjects:[UIImage imageNamed:@"img1.jpg"],[UIImage imageNamed:@"img2.jpg"],[UIImage imageNamed:@"img3.jpg"],[UIImage imageNamed:@"img4.jpg"], nil];
    pagecontrol = [[UIPageControl alloc]init];
    self.imageIndex = 0;
    [pagecontrol setNumberOfPages:images.count];
    [pagecontrol setCurrentPage:imageIndex]; 
就像你可以看到的,我有一个由四幅图像组成的数组。我在imageview上添加了一个pagecontrol。我还在imageView上添加了两个滑动手势(左和右)。我现在想做的是,当我刷卡时:

  • 图像已更改
  • 点在数组中的正确位置被更新
这是我右击的代码:

- (void)next:(UITapGestureRecognizer *)recognizer {
    if(imageIndex == images.count-1){
        imageIndex = images.count-1;
    }else{
        imageIndex++;
    }
    [UIView transitionWithView:self.imgGallery
                      duration:1.0f
                       options:UIViewAnimationOptionTransitionCrossDissolve
                    animations:^{
                        self.imgGallery.image = [images objectAtIndex:imageIndex];

                    } completion:nil];
    [pagecontrol setCurrentPage:imageIndex];
}
问题

我的图像正在正确地改变。但是我的页面控制点没有更新,而且它只显示了3个点


有人能帮忙吗?

在哪里定义页面控件

 [_tutorialPageControll addTarget:self action:@selector(changPage) forControlEvents:UIControlEventValueChanged];
_tutorialPageControll.currentPage = 0;
    _tutorialPageControll.numberOfPages = TutorialArray.count;
在你想换一张纸的地方

_tutorialPageControll.currentPage = imageIndex;
  • 在scrollview中启用分页
  • [self.scrollView setPaginEnabled:是]

  • 将委托设置为滚动视图

  • 将当前页面值设置为3或4(0除外),并在加载页面控件时检查点是否正确放置@Stef GeelenI没有滚动视图?它应该始终与滚动视图结合使用吗?