简体   繁体   中英

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)

对于那些有同样问题的人(像我一样),已经寻找了最近几个小时,但仍然无法找出问题所在,这是我犯的愚蠢错误,导致了这个问题:原来,我的viewController是UIPageViewController的实例,而不是UIViewController的实例。

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

For example

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM