uipageviewcontroller类在设置多个视图控制器时崩溃 [英] uipageviewcontroller class crashing on setting more than one view controllers

查看:280
本文介绍了uipageviewcontroller类在设置多个视图控制器时崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在应用程序中设置多个视图控制器时,我的应用程序总是崩溃,如下所示.

My app keeps crashing, when I set more than one view controller in my app, like below.

[self setViewControllers:_images direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL];

我的图像是视图控制器的数组.

My images is an array of view controllers.

应用程序崩溃,并显示以下错误.我不知道从哪里开始.

The app crashes saying the following error. I have no idea where to start.

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'The number of view controllers provided (9) doesn't match the number required (1) for the requested transition

推荐答案

如错误所示,您提供的视图控制器超出了需要.您应该在阵列中仅提供1个视图控制器.然后,使用页面视图控制器的dataSource方法正确提供视图控制器之前和之后的内容.

As the error says,you are providing more view controllers than needed. You should provide only 1 view controller in an array. Then use page view controller's dataSource methods to provide before and after view controllers properly.

这篇关于uipageviewcontroller类在设置多个视图控制器时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆