简体   繁体   English

在UITabBarController上选择选项卡时,如何显示ViewController?

[英]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.

相关问题 从UITabBarController以模态方式呈现ViewController而不隐藏选项卡栏 - Present ViewController modally from UITabBarController without hiding the tab bar 在UITabBarController中选择了不同选项卡时,如何添加具有不同颜色的下划线 - How to add Underline with different color when different tab is selected in UITabBarController 从 UITabbarController 选择选项卡时如何更新 VC 中的值? - How to update the value in a VC when a tab is selected from a UITabbarController? 检测何时选择UITabBarController More选项卡 - Detect when UITabBarController More tab is selected 如何在选择tabBar项时以模态方式呈现viewController - How to present a viewController modally when it's tabBar item is selected TabBarController进入视图时如何设置UITabBarController不选择任何选项卡(ViewController) - How to Set UITabBarController to not select any Tab (ViewController) when TabBarController comes to View UITabBarController在不同选项卡中具有相同的ViewController - UITabBarController with same ViewController in different tab UITabBarController选择的选项卡错误(?) - UITabBarController selected tab bug (?) 如何为每个标签使用使用相同ViewController的UITabBarController? - How do I use a UITabBarController using the same ViewController for every tab? 如何将UITabBarController导航到ViewController? - How to navigate UITabBarController to ViewController?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM