swift3: How to Present xib to viewcontroller

1.5k views Asked by At

I have added xib on another xib class as subview and unable to present from xib to view controller (Story Board controller). I tried following

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)

Non of this worked for me

Thanks in advance

1

There are 1 answers

10
Satyanarayana On BEST ANSWER

try like this

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