简体   繁体   中英

Cannot convert value of type'[AnyObject]'to expected argument type '[UIViewController]?'

private func createPageViewController() {
    let pageViewController = self.storyboard?.instantiateViewControllerWithIdentifier("PageViewController") as! UIPageViewController
    pageViewController.dataSource = self
    pageViewController.delegate = self

    if contentImages.count > 0 {
        let firstVC = self.getItemController(0)!
        let startingVCs: NSArray = [firstVC]
        pageViewController.setViewControllers(startingVCs as [AnyObject] as [AnyObject], direction: .Forward, animated: false, completion: nil)
    }

change this

pageViewController.setViewControllers(startingVCs as [AnyObject] as [AnyObject], direction: .Forward, animated: false, completion: nil)

into

The viewControllers parameter is now a [UIViewController] . So your viewControllers array that you pass in must be [UIViewController] .

pageViewController.setViewControllers(startingVCs as [UIViewController], direction: .Forward, animated: false, completion: nil)

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