如何在Swift中控制UIPageViewController项索引?
我已经设置了一个如何在Swift中控制UIPageViewController项索引?,swift,uiviewcontroller,uipageviewcontroller,Swift,Uiviewcontroller,Uipageviewcontroller,我已经设置了一个UIPageViewController。因此,我有两个uiviewcontroller和一个UIPageViewController 我正在使用此代码,当用户向前或向后滑动时,我希望减少或增加一个名为“character”的变量 class PageItemController: UIViewController { /* As we’ll have only one class for all content controllers, we need to somehow
UIPageViewController
。因此,我有两个uiviewcontroller
和一个UIPageViewController
我正在使用此代码,当用户向前或向后滑动时,我希望减少或增加一个名为“character”的变量
class PageItemController: UIViewController {
/* As we’ll have only one class for all content controllers, we need to somehow identify different content items. In order to do it, each PageItemController should have its index and image name.*/
var itemIndex: Int = 0 {
didSet {
if itemIndex == 0 {
character = 1
}
if itemIndex == 1 {
character = 2
}
}
}
...
}
我正在做的是:
UIPageControllers
方法被激活时,您需要通过设置多个变量并编辑它们的值来解决问题