开发者

UITabBarController tab to act as a Logout button instead of showing the corresponding view

开发者 https://www.devze.com 2023-01-30 21:10 出处:网络
I have a UITabBarController based iphone application. I added开发者_开发技巧 a new tab called Log Out via the Interface Builder.

I have a UITabBarController based iphone application. I added开发者_开发技巧 a new tab called Log Out via the Interface Builder.

However I don't need its corresponding view. I want the Log Out tab to redirect to the Login view as soon as it is clicked (of course some session clearing code is executed as well).

The nearest I've got so far is to redirect from the Log Out View using the viewWillAppear. The result is the same but it doesnt look great because it goes into a blank screen for a couple of seconds and then it redirect to the login screen.

Any help would be appreciated.


You can use UITabbarDelegate methods to accomplish this

Use following delegate method to check for logout buttons index and if found then perform your tasks

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{

       if (tabBarController.selectedIndex == 4)
       {
         // perform logout tasks
       }


}
0

精彩评论

暂无评论...
验证码 换一张
取 消