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!
sry taken answer here, missed (you have no view in xib add 1 , this):
if using xib
follow
follo following steps
1) open xib file right click on files owner , drag first view
2) bind view outlet of "view"
hope it...
Comments
Post a Comment