Reputation: 27292
I'm new to iOS development, and I'm struggling to understand how the pieces fit together, and how to best use the Interface Builder (yes, I want to use IB and understand how it relates to changes in code).
Here's my current scenario:
I created a class PageViewController : UIPageViewController
, which I have associated with my "Page View Controller Scene" in IB. This is the initial view controller.
I created a class Page1ViewController : UIViewController
, which I have associated with "Page1 View Controller Scene" in IB. Also in IB, I have added a UIView
to that scene, that has an opaque white background and a single label in it.
In PageViewController
's viewDidLoad
method, I do the following:
setViewControllers([Page1ViewController()],
direction: UIPageViewControllerNavigationDirection.Forward,
animated: true, completion: nil)
In both the viewDidLoad
method of both PageViewController
and Page1ViewController
, I have a println
and both are displaying, so I know they are getting loaded...but when I run my app, I have a blank black screen.
Here's what I am trying to accomplish:
PageViewController
has multiple custom pages that I want to design in IB (they are not like the out-of-the-box calendar example, where a data source determines each page view)
When the app starts, I want PageViewController
to display the first page (PageView1Controller
)
I'm comfortable with Swift, but the UIKit framework is a little daunting at the moment. Any guidance would be appreciated.
Upvotes: 2
Views: 110
Reputation: 326
I know you've said you set the PageViewController as your initial view controller but are you sure you did this correctly. It should look similar to the screenshot below.
Ive just done a simple project with a page controller and then its in view did load did the following:-
let pagevc1 = UIViewController()
pagevc1.view.backgroundColor = UIColor.redColor()
self.setViewControllers([pagevc1], direction: UIPageViewControllerNavigationDirection.Forward, animated: true, completion: nil)
Which seems to display fine. How are you initialising the Page1ViewController view controller?
Upvotes: 1