Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIPageViewController具有未知数量的UIViewController实例_Ios_Swift_Uiviewcontroller_Uipageviewcontroller - Fatal编程技术网

Ios UIPageViewController具有未知数量的UIViewController实例

Ios UIPageViewController具有未知数量的UIViewController实例,ios,swift,uiviewcontroller,uipageviewcontroller,Ios,Swift,Uiviewcontroller,Uipageviewcontroller,我想创建一个UIPageViewController,它只使用一个UIViewController,但它的每个新实例每次都会保存不同的数据。UIPageViewController每次[previous][current][next]需要保存3个UIViewController实例,并在运行中加载下一个或上一个实例。重要的是我不使用故事板 我找到了链接,但我不知道怎么做,因为在setupPageController()上,他正在用他以前创建的UIViewControllers初始化UIPageV

我想创建一个
UIPageViewController
,它只使用一个
UIViewController
,但它的每个新实例每次都会保存不同的数据。
UIPageViewController
每次[previous][current][next]需要保存3个
UIViewController
实例,并在运行中加载下一个或上一个实例。重要的是我不使用故事板

我找到了链接,但我不知道怎么做,因为在
setupPageController()
上,他正在用他以前创建的
UIViewControllers
初始化
UIPageViewController
pageViewController.setViewControllers

正确和最好的方法是什么

UIPageViewController需要容纳3个实例


不,没有。页面视图控制器没有固定的页面集;它只有一页。您不需要提前计划来提前创建任何其他页面。这就是重点。当您收到用户想要下一个或上一个页面的通知时,您可以立即决定它将是什么并创建它。你可以使用任何你喜欢的逻辑

此示例显示了一个典型的体系结构。我为每个页面使用同一视图控制器的不同实例。我在数据源方法中的逻辑很简单;你的可能很不一样。但基本架构总是这样。