简体   繁体   English

UIPageViewController的第一页显示黑屏且未加载内容

[英]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. 我有一个UIPageViewController,它可以翻转页面,并且所有页面都可以正确加载,除了第一页保持黑色并且加载图标没有消失。 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) 这是我设置pageviewcontroller的第一个视图的方法的外观(这是对从后端获取信息的函数的回调)

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? 您是否在getItemController方法中实例化了起始视图控制器?

For example 例如

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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