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

javascript - three.js lot of meshes optimization -

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -