[英]How to present ViewController when tab is selected on UITabBarController?
I have a UITabBarController with a profile tab. 我有一个带有配置文件选项卡的UITabBarController。 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 您需要使用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 https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITabBarControllerDelegate_Protocol/index.html#//apple_ref/occ/intf/UITabBarControllerDelegate
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.