开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜