ios - UIPageControl - 单击按钮更改页面

标签 ios uiviewcontroller uibutton uipagecontrol

我正在使用 UIPageControlUISwipeGestureRecognizer 在 View Controller 之间切换。使用滑动更改页面。

我还需要在其中一个 View Controller 上按下 UIButton 时更改页面。

以下是如何使用滑动来更改 View :

- (void)swipeRightToLeftGesture:(UIGestureRecognizer *)gestureRecognizer {
    if (self.pageControl.currentPage == 0) { 
       [UIView animateWithDuration:1
                 animations:^{

                     for (UIViewController *vc in self.childViewControllers) {
                         CGRect frame = vc.view.frame;
                         frame.origin.x -= self.view.frame.size.height;
                         vc.view.frame = frame;
                 }
      }];
      self.pageControl.currentPage = 1;
   }
}

我希望问题很清楚。我尽力说清楚了。

最佳答案

这有点厚颜无耻,真的你应该重构这个方法,但是:

假设您在第 0 页(我想第 1 页上有一个不同的按钮),那么您可以调用您的方法并将 nil 作为参数传递。该手势实际上并未使用,因此一切都应该没问题。

关于ios - UIPageControl - 单击按钮更改页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21195283/

相关文章:

iphone - 如何从 iphone 的图库中设置 Uibutton 中的背景

ios - 当我从基类以编程方式替换 UIViewController 的根 UIView 时,我的 Outlets 为零

swift - 我必须使用协议(protocol)/委托(delegate)来让 ViewController 执行在另一个类中创建的 UIButton 的操作吗?

iphone - 组合图像制作 UIButton?

ios - 是否可以在带有推送通知的同一应用程序中同时使用 App Store 和 In House 配置文件?

iOS 将极坐标定义的区域转换为 NxN 矩阵

iOS Swift 将值 append 到数组

iOS 7 表格 View 横向单元格宽度

objective-c - 如何以编程方式触发方法 "tabBarController:didSelectViewController:"?

xcode - 导航后退栏与之前的 View 标题没有变化