我是 iOS 开发的新手,我很难理解这些部分是如何组合在一起的,以及如何最好地使用 Interface Builder(是的,我想使用 IB 并且了解如何它与代码的更改有关)。
这是我目前的场景:
我创建了一个类
PageViewController : UIPageViewController
,我已将其与 IB 中的“页面 View Controller 场景”相关联。这是初始 View Controller 。我创建了一个类
Page1ViewController : UIViewController
,我在 IB 中将其与“Page1 View Controller Scene”相关联。同样在 IB 中,我向那个场景添加了一个UIView
,它有一个不透明的白色背景和一个标签。在
PageViewController
的viewDidLoad
方法中,我执行以下操作:setViewControllers([Page1ViewController()], 方向:UIPageViewControllerNavigationDirection.Forward, 动画:真,完成:无)
在 PageViewController
和 Page1ViewController
的 viewDidLoad
方法中,我都有一个 println
并且都在显示, 所以我知道它们正在加载...但是当我运行我的应用程序时,我有一个空白的黑屏。
这是我想要完成的:
PageViewController
有多个我想在 IB 中设计的自定义页面(它们不像开箱即用的日历示例,其中数据源决定每个页面 View )当应用程序启动时,我希望
PageViewController
显示第一页 (PageView1Controller
)
我对 Swift 很满意,但 UIKit 框架目前有点让人望而生畏。任何指导将不胜感激。
最佳答案
我知道您说过您将 PageViewController 设置为您的初始 View Controller ,但您确定这样做是正确的吗?它看起来应该类似于下面的屏幕截图。
我刚刚用页面 Controller 完成了一个简单的项目,然后它的 View 确实加载了以下内容:-
let pagevc1 = UIViewController()
pagevc1.view.backgroundColor = UIColor.redColor()
self.setViewControllers([pagevc1], direction: UIPageViewControllerNavigationDirection.Forward, animated: true, completion: nil)
这似乎显示正常。您如何初始化 Page1ViewController View Controller ?
关于ios - 我的 UIView 没有呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27491691/