iphone - Changing rootviewcontroller for navigation controller dynamically -
i'm trying change rootviewcontroller navigationcontroller in didfinishlaunchingwithoptions.
don't know how can that.
i have gone through link well:
http://starterstep.wordpress.com/2009/03/05/changing-a-uinavigationcontroller%e2%80%99s-root-view-controller/
here code in didfinishlaunchingwithoptions:
- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]; uiviewcontroller *rootcontroller=[[homepagecontroller alloc] initwithnibname:@"homepagecontroller" bundle:nil]; navigationcontroller=[[uinavigationcontroller alloc] initwithrootviewcontroller:rootcontroller]; // presentation=[[presentationcontroller alloc]initwithnibname:@"presentationcontroller" bundle:nil]; // // navigationcontroller=[[uinavigationcontroller alloc]initwithrootviewcontroller:presentation]; // // presentationlist=[[presentationlistcontroller alloc]initwithnibname:@"presentationlistcontroller" bundle:nil]; // // uinavigationcontroller *listnavigation = [[uinavigationcontroller alloc] initwithrootviewcontroller:presentationlist]; // // revealer=[[zuuirevealcontroller alloc]initwithfrontviewcontroller:navigationcontroller rearviewcontroller:listnavigation]; [self.window addsubview:navigationcontroller.view]; [self.window makekeyandvisible]; return yes; } right comment , run application change rootviewcontroller. not practical approach.
any appreciated.
instead of this:
[self.window addsubview:navigationcontroller.view]; put this:
self.window.rootviewcontroller = navigationcontroller;
Comments
Post a Comment