简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM