I'm approaching to swift in this days and I've a question.
What if I have to create programmatically a new UIViewController?
Easy with an empty/new view controller:
var controller: UIViewController = UIViewController()
controller.view.backgroundColor = UIColor.whiteColor()
self.presentViewController(controller, animated: true, completion: nil)
Now, I have a xib file that I would like to load on the controller:
var controller: UIViewController = UIViewController(nibName: "FeedDetail", bundle: nil)
controller.view.backgroundColor = UIColor.whiteColor()
self.presentViewController(controller, animated: true, completion: nil)
This crash because:
'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "FeedDetail" nib but the view outlet was not set.'
I've already read this post and I can't understand what's wrong!
Sry I taken the answer from here, you missed something like (You have no view in xib so add one and then do this):
if you are using Xib
follow this
follo following steps
1) open your xib file then right click on files owner and drag to your first view
2) then bind that view with outlet of "view"
hope you will get it...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With