Ios Swift 2语法错误与方向。前进

Ios Swift 2语法错误与方向。前进,ios,swift,syntax-error,swift2,Ios,Swift,Syntax Error,Swift2,第二天,我在Swift 1.2中写道: self.pageViewController.setViewControllers(viewControllers as [AnyObject], direction: .Forward, animated: true, completion: nil) 但是现在,在Swift 2中,它向我显示了下一个错误: Could not find member 'Forward' 如何修复它?您应该确保ViewController不是可选类型。例如: var

第二天,我在Swift 1.2中写道:

self.pageViewController.setViewControllers(viewControllers as [AnyObject], direction: .Forward, animated: true, completion: nil)
但是现在,在Swift 2中,它向我显示了下一个错误:

Could not find member 'Forward'

如何修复它?

您应该确保ViewController不是可选类型。例如:

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

您应该确保ViewController不是可选类型。例如:

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

您是否尝试过UIPageViewControllerNavigationDirection.Forward而不是.Forward?在这种情况下,它会打印
动画:true
部分下一个错误
'Bool'不能转换为'BooleanLiteralConverable'
错误可能在第一个参数中,该参数的类型应为
[UIViewController]?
。尝试将
作为[AnyObject]
删除(取决于ViewController的声明方式).您是否尝试过UIPageViewControllerNavigationDirection.Forward而不是.Forward?在这种情况下,它会打印
动画:true
部分下一个错误
“Bool”不能转换为“booleanLiteralConverable”
错误可能在第一个参数中,该参数的类型应为
[UIViewController]?
。尝试将
作为[AnyObject]
删除(取决于ViewController的声明方式)。