Instantiate and Present a viewController in Swift
Question
How to instantiate and then presenting a viewController from a specific storyboard?
Answer
Swift 3
1 | let storyboard = UIStoryboard(name: "MyStoryboardName", bundle: nil) |
Issue
For people using this answer to instantiate UIViewController
and are having the exception:
fatal error: use of unimplemented initializer ‘init(coder:)’ for class
Solution
Manually implement init(coder: NSCoder!)
at your destination UIViewController that you are trying to instantiate.1
2
3init(coder aDecoder: NSCoder!) {
super.init(coder: aDecoder)
}
If you need more description please refer to this answer here
Reference
- Instantiate and Present a viewController in Swift
- Fatal error: use of unimplemented initializer ‘init(coder:)’ for class
This is the end of post