有没有办法不分配 UIModalTransitionStyle?
Is there any way to assign no UIModalTransitionStyle?
我知道 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
时,编译器将从 UIViewController
.
的 Storyboard 文档中获取 modalTransitionStyle
如何设置不modalTransitionStyle
?
如果您不想要过渡,您应该在展示新视图控制器时将 animated
属性 设置为 false
。
self.presentViewController(vc, animated: false, completion: nil)
我知道 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
时,编译器将从 UIViewController
.
modalTransitionStyle
如何设置不modalTransitionStyle
?
如果您不想要过渡,您应该在展示新视图控制器时将 animated
属性 设置为 false
。
self.presentViewController(vc, animated: false, completion: nil)