我知道UIModalTransitionStyle
有四种类型,但我不想使用其中任何一种。
但是,此代码不起作用:
@IBAction func button(sender: AnyObject) {
let modalView = ViewController()
let storyboard = UIStoryboard(name: "Universal", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("ViewController") as UIViewController
modalView.modalTransitionStyle = nil // Error: type 'UIModalTransitionStyle' does not conform to protocol 'NilLiteralConvertible'
self.presentViewController(vc, animated: true, completion: nil)
}
每当我不指定modalTransitionStyle
时,编译器将从modalTransitionStyle
的故事板文档中获取UIViewController
。
如何设置modalTransitionStyle
?
答案 0 :(得分:5)
如果您不想进行转换,则应在展示新视图控制器时将animated
属性设置为false
。
self.presentViewController(vc, animated: false, completion: nil)