ios - Best approach to switch between TabBarController and ViewController -


i have been trying app initial login screen takes tabbarcontroller.
want know whats best approach example code appreciated. have tried unable switch viewcontroller tabcontroller.

i'm not sure best way it, it's quick , dirty , works. present modal view controller inside applicationdidfinishlaunchinewithoptions: method. should replace @selector more appropriate want do. background color effect only.

- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions {     self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]];     // override point customization after application launch.     uiviewcontroller *viewcontroller1 = [[firstviewcontroller alloc] initwithnibname:@"firstviewcontroller" bundle:nil];     uiviewcontroller *viewcontroller2 = [[secondviewcontroller alloc] initwithnibname:@"secondviewcontroller" bundle:nil];     self.tabbarcontroller = [[uitabbarcontroller alloc] init];     self.tabbarcontroller.viewcontrollers = @[viewcontroller1, viewcontroller2];     self.window.rootviewcontroller = self.tabbarcontroller;       [self.window makekeyandvisible];       // ***** relevant code *****     uiviewcontroller *viewcontroller = [[uiviewcontroller alloc] init];     uinavigationcontroller *navigationcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller:viewcontroller];     [[viewcontroller view] setbackgroundcolor:[uicolor redcolor]];     uibutton *dismissbutton = [uibutton buttonwithtype:uibuttontyperoundedrect];     [dismissbutton setframe:cgrectmake(10, 10, 300, 44)];     [dismissbutton settitle:@"dismiss" forstate:uicontrolstatenormal];     [dismissbutton addtarget:[self tabbarcontroller] action:@selector(dismissmodalviewcontrolleranimated:) forcontrolevents:uicontroleventtouchupinside];     [[viewcontroller view] addsubview:dismissbutton];     [[self tabbarcontroller] presentviewcontroller:navigationcontroller animated:no completion:nil];      return yes; } 

i wouldn't put sort of code in app delegate, if it's one-time thing login details, maybe it's ok.

enter image description here


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -