是否可以从选项卡访问常规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屋!