- (UIVIEwController *)pageVIEwController:(UIPageVIEwController *)pageVIEwController vIEwControllerBeforeVIEwController:(UIVIEwController *)vIEwController;- (UIVIEwController *)pageVIEwController:(UIPageVIEwController *)pageVIEwController vIEwControllerAfterVIEwController:(UIVIEwController *)vIEwController;
如果用户点击按钮,我可以做同样的事吗?
解决方法 您可以使用setVIEwControllers:direction:animated:completion:在页面视图控制器上以编程方式设置当前显示的视图控制器.这是一个显示具有随机背景颜色的视图控制器的示例.您可以调整此选项以使用特定的视图控制器.
- (voID)vIEwDIDLoad{ [super vIEwDIDLoad]; self.pvc = [[UIPageVIEwController alloc] initWithTransitionStyle:UIPageVIEwControllerTransitionStyleScroll navigationorIEntation:UIPageVIEwControllerNavigationorIEntationHorizontal options:nil]; self.pvc.vIEw.frame = CGRectInset(self.vIEw.bounds,200,200); [self.vIEw addSubvIEw:self.pvc.vIEw]; [self.pvc setVIEwControllers:@[[self randomVC]] direction:UIPageVIEwControllerNavigationDirectionForward animated:YES completion:nil];}-(UIVIEwController*)randomVC{ UIVIEwController *vc = [[UIVIEwController alloc] init]; UIcolor *color = [UIcolor colorWithRed:arc4random_uniform(255)/255.0 green:arc4random_uniform(255)/255.0 blue:arc4random_uniform(255)/255.0 Alpha:1]; vc.vIEw.backgroundcolor = color; return vc;}- (IBAction)prevIoUsbuttonpressed:(ID)sender { [self.pvc setVIEwControllers:@[[self randomVC]] direction:UIPageVIEwControllerNavigationDirectionReverse animated:YES completion:nil];}- (IBAction)nextbuttonpressed:(ID)sender { [self.pvc setVIEwControllers:@[[self randomVC]] direction:UIPageVIEwControllerNavigationDirectionForward animated:YES completion:nil];}总结
以上是内存溢出为你收集整理的iOS:UIPageViewController – 使用按钮跳转到下一页全部内容,希望文章能够帮你解决iOS:UIPageViewController – 使用按钮跳转到下一页所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)