Referencing a programatically created UINavigationBar from within a XIB
I got some of this code from another stackoverflow answer of how to add UINavbars to a UIToolBar
I do feel a little dumb here because I cant figure out how to reference a newly created NavController from the nib that I want it to display... this is what I am doing. I know I must have mixed something up here :(
In my app delegate I created the array of controllers:
UINavigationController *rvc_tools = [[UINavigationController alloc]
initWithRootViewController: navController_tools];
UINavigationController *rvc_settings = [[UINavigationController alloc] initWithRootViewController:navController_settings];
aboutIVacation* vc_about = [[aboutIVacation alloc] init];
myCurrent *mycurrentpage = [[myCurrent alloc] init];
UINavigationController *rvc_mysynchpage = [[UINavigationController alloc] initWithRootViewController:navController_synch];
//And then I added it to the tab bar:
<code> NSArray* controllers = [NSArray arrayWithObjects: mycurrentpage, rvc_tools,rvc_settings, vc_about, rvs_mysynchpage, nil];</code>
[iVacationTabBar setViewControllers: controllers animated:NO]; So now if I want rvc_mysynchpage to load my xib called "synch" how do I tell it to l开发者_如何学运维oad that and once I am in my xib called synch and I have a button I want to push that shows pushes another view on top to do something, how do I have it push the new view.
If I try to call rvc_mysynchpage it will tell me its undeclared....
I just figured it out!!!!
To push a view controller on to the stack, it knows automatically what nav controller called it their and has that reference to it, you just do this:
[self.navigationController pushViewController:nameofcontroller animated: YES];
精彩评论