2011-02-02 130 views
0

當我的應用第一次啓動時,它會顯示一個登錄Facebook的主頁面。然後,它進入UITabBarController。我有我的應用程序委託,代碼如下:將Facebook上的信息傳遞給UITabBarController

//this is the .h 
@interface NMeAppDelegate : NSObject <UIApplicationDelegate> { 
    UIWindow *window; 
    MainViewController *controller; 
    UITabBarController *tabBar; 
} 

@property (nonatomic, retain) IBOutlet UITabBarController *tabBar; 
@property (nonatomic, retain) MainViewController *controller; 
@property (nonatomic, retain) IBOutlet UIWindow *window; 

@end 

//this is the .m of the app delegate 
#import "NMeAppDelegate.h" 

@implementation NMeAppDelegate 

@synthesize window; 
@synthesize tabBar; 
@synthesize controller; 

#pragma mark - 
#pragma mark Application lifecycle 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  

    // Override point for customization after application launch. 
    controller = [[MainViewController alloc] init]; 
    [window addSubview:tabBar.view]; 
    [window addSubview:controller.view]; 
    [window makeKeyAndVisible]; 

    return YES; 
} 

裏面的MainViewController,其實我有一個的UserInfo對象,它擁有所有我需要的的UITabBarController的信息。問題是,在UITabViewController中獲取此信息後,如何將此UserInfo傳遞給UITabBarController`或可能位於UITabBarController內部的ViewController,以便他們能夠訪問此UserInfo?這個怎麼做?

我希望我的問題有道理。

+0

恐怕你所希望的沒有成爲現實:你的問題沒有道理:)請清楚地說明你正在努力達到的目標以及正在發生的事情。 – 2011-02-02 23:19:56

回答

0

您需要有一個可用於選項卡欄控制器的UserInfo對象的實例。可能會在您轉換到指定控制器時將其傳遞到您的UItabBarController /每個視圖控制器中的UserInfo類型的實例變量。編輯:你真的應該把它傳遞給它所需要的視圖控制器(因爲它沒有出現你有一個自定義的UITabBarController子類),或者你可以在你的應用程序委託中使用一個共享的UserInfo變量來保持隨信息一起提供。

但正如評論者所說,這個問題根本不是很清楚,我完全可能會誤解你想做的事情。

希望有所幫助。