Swift 2 syntax error with direction .Forward

眉间皱痕 提交于 2020-01-15 20:52:58

问题


I wrote in Swift 1.2 the next:

self.pageViewController.setViewControllers(viewControllers as [AnyObject], direction: .Forward, animated: true, completion: nil)

but now, in Swift 2 it prints me the next error:

Could not find member 'Forward'

How can I fix it?


回答1:


You should make sure that your viewControllers not optional Type. Such as:

var viewControllers:[UIViewController] = [VC1,VC2]
self.pageViewController.setViewControllers(viewControllers, direction: UIPageViewControllerNavigationDirection.Forward, animated: true, completion: nil)


来源:https://stackoverflow.com/questions/32564132/swift-2-syntax-error-with-direction-forward

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!