Swift 2 语法错误,方向 .Forward
Swift 2 syntax error with direction .Forward
我写在Swift1.2下:
self.pageViewController.setViewControllers(viewControllers as [AnyObject], direction: .Forward, animated: true, completion: nil)
但是现在,在 Swift 2 中,它向我打印了下一个错误:
Could not find member 'Forward'
我该如何解决?
您应该确保您的 viewControllers 不是可选类型。如:
var viewControllers:[UIViewController] = [VC1,VC2]
self.pageViewController.setViewControllers(viewControllers, direction: UIPageViewControllerNavigationDirection.Forward, animated: true, completion: nil)
我写在Swift1.2下:
self.pageViewController.setViewControllers(viewControllers as [AnyObject], direction: .Forward, animated: true, completion: nil)
但是现在,在 Swift 2 中,它向我打印了下一个错误:
Could not find member 'Forward'
我该如何解决?
您应该确保您的 viewControllers 不是可选类型。如:
var viewControllers:[UIViewController] = [VC1,VC2]
self.pageViewController.setViewControllers(viewControllers, direction: UIPageViewControllerNavigationDirection.Forward, animated: true, completion: nil)