ios - How to add/connect NIB to programmatically created UINavigationController? -


first of all, i'm beginner, might have concepts wrong.

this code in appdelegate.m:

- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions {     uiviewcontroller *viewcontroller = [[uiviewcontroller alloc] initwithnibname:@"firstview" bundle:nil];     self.navigationcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller: viewcontroller];      self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]];     // override point customization after application launch.     self.window.backgroundcolor = [uicolor whitecolor];     self.window.rootviewcontroller = self.navigationcontroller;     [self.window makekeyandvisible];     return yes; } 

the idea programmatically add uinavigationcontroller, use .xib (the "firstview" paremeter) views. have no problem programmatically creating views well, simpler interfaces, assume using ib can done well.

however, when run code, error:

2013-07-11 21:20:42.644 new-book-proto-01[64308:11303] *** terminating app due uncaught exception 'nsinternalinconsistencyexception', reason:  '-[uiviewcontroller _loadviewfromnibnamed:bundle:] loaded "firstview" nib view outlet not set.'  

what should do? there missing?

additionally, common in ios development? bad practice? there better way this?

this reason told: "reason: '-[uiviewcontroller _loadviewfromnibnamed:bundle:] loaded "firstview" nib view outlet not set.' "

it means try access or value views (ui elements) has not iboutlet in controller class or have none view @ all

you should create iboutlets (properties) each view (each ui element view) "see" in controller


Comments