有没有办法不分配UIModalTransitionStyle?

时间:2015-02-20 09:41:02

标签: ios swift 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时,编译器将从modalTransitionStyle的故事板文档中获取UIViewController

如何设置modalTransitionStyle

1 个答案:

答案 0 :(得分:5)

如果您不想进行转换,则应在展示新视图控制器时将animated属性设置为false

self.presentViewController(vc, animated: false, completion: nil)