Swift UIPageViewController没有加载初始视图

时间:2015-07-25 23:27:22

标签: ios swift uipageviewcontroller

我有一个UIPageViewController作为我的初始视图。我加载了3个视图控制器,然后我尝试将其中一个设置为初始控制器。

let defaultView = UIViewController()
print("called")
defaultView.view.backgroundColor = UIColor.yellowColor()
let viewController = NSArray(object: defaultView) as [AnyObject]
self.setViewControllers(viewController, direction: UIPageViewControllerNavigationDirection.Forward, animated: false, completion: nil)

看来这段代码什么也没做。视图只是黑色,并且视图控制器未加载。奇怪的是,如果向右或向左滑动,我会看到我制作的其他一些UIViewControllers。有什么想法吗?如有必要,我可以发布更多代码。

1 个答案:

答案 0 :(得分:0)

好的,我明白了。我没有打电话给setViewControllers就覆盖了super