3

我知道有四种类型的UIModalTransitionStyles,但我不想使用其中任何一种。

但是,此代码不起作用:

@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从 Storyboard 文档中获取UIViewController.

如何设置 no modalTransitionStyle

4

1 回答 1

7

如果您不想要过渡,则应在呈现新视图控制器时将该animated属性设置为。false

self.presentViewController(vc, animated: false, completion: nil)
于 2015-02-20T09:51:13.320 回答