iphone - Switch from TabBarView back to Standard View -
i have implemeneted application login, , once log in brings tab bar view. however, want implement log out button when user pushes button brings them login view.
i have following code right now, dosn't work. uibarbutton being invoked, because producing nslog output gdb. dosn't switch views.
in view tab bar.
- (ibaction) logoutbuttonpushed { nslog(@"yes, pushed"); [self.appdelegate logout]; } then in app delegate.
// logout , return welcome view - (void) logout { [self.tabbarviewcontroller.view removefromsuperview]; [window addsubview:self.welcomeviewcontroller.view]; [window bringsubviewtofront:self.welcomeviewcontroller.view]; [usermodel logout]; } just kicks, here how bring tab bar front.
// switches tab bar view either welcome or registersuccess view - (void) switchtotabbarview { [self.registersuccessviewcontroller.view removefromsuperview]; [self.welcomeviewcontroller.view removefromsuperview]; [window addsubview:self.tabbarviewcontroller.view]; [window bringsubviewtofront:self.tabbarviewcontroller.view]; } any help, or suggestions improve code (i have many bad practice) welcomed. thanks!
refer answer question.
you should not use self, because won't refer tabbar controller. instead of self, use instance of view controller placed tabbar controller
in appdelegate.h
yourviewcontroller *yourviewcontrollerobj; @property(nonatomic,retain) yourviewcontroller *yourviewcontrollerobj; in appdelegate.m
@synthesize yourviewcontrollerobj; in yourviewcontroller.m, set object appdelegate instance:
- (void)viewdidload { appdelegate.yourviewcontrollerobj = self; //do ever u want } then in logout function
- (ibaction) logoutbuttonpushed { nslog(@"yes, pushed"); loginscreen *loginscreenobj = [[loginscreen alloc] initwithnibname:@"loginscreen" bundle:[nsbundle mainbundle]]; [appdelegate.yourviewcontrollerobj presentmodalviewcontroller:loginscreenobj animated:yes]; [loginscreenobj release]; }
Comments
Post a Comment