从它的选项卡访问常规 UITabBarController 属性? [英] Access to General UITabBarController properties from it's tabs?
问题描述
我会描述我想做什么.我有登录页面(ViewController).
I'll describe what I want to do. I have Login page(ViewController).
登录后,我传递给 UITabBarController - MainTabBar.m.这个 MainTabBar 有 'key' 属性,它从登录页面获取用户密钥.
After I login I pass to UITabBarController - MainTabBar.m. This MainTabBar has 'key' property, which gets the user key from the login page.
UITabBarController 有 2 个选项卡 - Tab1.m、Tab2.m.
The UITabBarController has 2 tabs - Tab1.m, Tab2.m.
我想从每个选项卡访问 MainTabBar 属性.
I want to access the MainTabBar propery from each tab.
我该怎么做?
谢谢!
推荐答案
假设 Tab1 和 Tab2 是 UIViewController 的子类,您可以访问 Tab1.m 或 Tab2.m 中的 key 属性,如下所示:
Assuming that Tab1 and Tab2 are UIViewController subclasses you can access the key property in either Tab1.m or Tab2.m as:
#import MainTabBar.h
//...//
// Getting the parent TabBarController
MainTabBar *parentTabBarController = (MainTabBar *)self.tabBarController;
// Getting the key property from the parent TabBarController
NSString *theUserKey = parentTabBarController.key;
希望对你有帮助!
这篇关于从它的选项卡访问常规 UITabBarController 属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!