我正在使用 UIPageControl
和 UISwipeGestureRecognizer
在 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/