ios - Swift: create programmatically UIViewController from xib -


i'm approaching swift in days , i've question.

what if have create programmatically new uiviewcontroller?

easy empty/new view controller:

var controller: uiviewcontroller = uiviewcontroller() controller.view.backgroundcolor = uicolor.whitecolor() self.presentviewcontroller(controller, animated: true, completion: nil) 

now, have xib file load on 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 "feeddetail" nib view outlet not set.' 

i've read post , can't understand what's wrong!

enter image description here

sry taken answer here, missed (you have no view in xib add 1 , this):

enter image description here

if using xib follow

follo following steps

1) open xib file right click on files owner , drag first view

enter image description here

2) bind view outlet of "view"

enter image description here

hope it...


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -