2013-05-22 51 views
-4

我創造的tabbarcontroller 4選項卡,我想在所有選項卡使用常見的變量,如姓名怎麼辦任何方式使用公共變量tabbarcontroller中的所有選項卡?

感謝

+0

請發表您的代碼,使我們看到你已經嘗試了什麼。 –

+0

爲什麼你需要知道你的標籤名稱?你不能只在你的NIB/XIB文件中分配它們嗎? – nielsbot

+0

我這樣做是通過使用self.navigationController.navigationBar.accessibilityValue – sabeer

回答

2

通過AppDelegate中聲明的對象將訪問所有四個標籤對象最簡單的方法。這樣做..

AppDelegate.h

@property (strong, nonatomic) NSString *strName; 

ViewController.m

#import "AppDelegate.h" 

AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; 
//Set Value 
appDelegate.strName = @"Some value"; 
//Get Value 
NSLog(@"%@",appDelegate.strName); 
+0

謝謝,但我不想創建一個變量 – sabeer

相關問題