swift3:如何将xib呈现给viewcontroller

时间:2017-01-06 05:15:21

标签: ios swift3 presentviewcontroller

我已将xib添加到另一个xib类作为子视图,并且无法从xib呈现给视图控制器(Story Board控制器)。 我试过跟着

1

let screen:Screen32ViewController = Screen32ViewController()
self.view.window?.rootViewController?.present(screen!, animated: true,  completion: nil)

2

let screen = self.storyboard?.instantiateViewController(withIdentifier: "Screen32ViewController") as? Screen32ViewController
self.present(screen!, animated: true,  completion: nil)

3

let screen:Screen32ViewController = Screen32ViewController()
self.present(screen!, animated: true,  completion: nil)

这不适用于我

提前致谢

1 个答案:

答案 0 :(得分:1)

试试这个

let screen = UIStoryboard(name: "storyboard name", bundle: nil).instantiateViewController(withIdentifier: "Screen32ViewController") as?   Screen32ViewController
self.present(screen!, animated: true,  completion: nil)