Search code examples
iosswiftuipageviewcontroller

First page of UIPageViewController showing black screen and not loading content


I have a UIPageViewController that is working to flip through pages and all of the pages load properly except for the first page it stays black and also the loading icon does not disappear. Here is what my method looks like for setting the first view of the pageviewcontroller (it is a callback to a function that grabs info from a backend)

self.card.images = cardImagesArray
activityIndicator.stopAnimating()
activityIndicator.removeFromSuperview()
self.cardImages = cardImagesArray
let startingViewController: UIViewController = getItemController(0)!
let viewControllers: NSArray = [startingViewController]
pageViewController!.setViewControllers(viewControllers as! [AnyObject], direction: .Forward, animated: false, completion: nil)

Solution

  • Did you instantiate your starting view controller in your getItemController method?

    For example

    let vc = self.storyboard?.instantiateViewControllerWithIdentifier("storyboardId") as! UIViewController