mergesort
mergesort

Reputation: 5187

How to present ViewController when tab is selected on UITabBarController?

I have a UITabBarController with a profile tab. I want to present a login view controller if the profile tab is pressed, but the user is not logged in. If the user presses cancel, I want the tab bar controller to have the same tab selected as before.

Upvotes: 0

Views: 291

Answers (1)

LLIAJLbHOu
LLIAJLbHOu

Reputation: 1313

You need to use UITabBarControllerDelegate

-tabBarController:shouldSelectViewController:

or

-tabBarController:didSelectViewController:

Detect your profile controller and present login controller.

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITabBarControllerDelegate_Protocol/index.html#//apple_ref/occ/intf/UITabBarControllerDelegate

Upvotes: 1

Related Questions