2011-03-30 27 views
0

我的應用程序有一個帶有4個視圖控制器的tabbarcontroller。iphone編程objective-c:viewDidLoad()執行

它這裏所說的:

self.window.rootViewController = tabBarController; 

,首先出現在的TabBar視圖控制器被稱爲「家」 我想打開的應用程序加載視圖 - 控制,而不僅僅是使用TabBar時。有可能的?我想從我的主視圖控制器調用ViewDidLoad()方法。謝謝

+0

在Objective-C中,通過附加括號來引用方法是不常見的。在這種情況下,方法的名稱只是'viewDidLoad'。爲了在類和實例方法之間消除歧義,分別預先分配一個「+」或「-'(即'-viewDidLoad')。 – dreamlax 2011-03-30 04:41:14

回答

0

如果您的應用程序基於TabBarController,您想要將viewControllers加載到TabBarController中,然後將TabBarControllers視圖添加到窗口中。例如:

FirstViewController *fvc = [[FirstViewController alloc] init]; 
SecondViewController *svc = [[SecondViewController alloc] init]; 

tabBarController.viewControllers = [NSArray arrayWithObjects:fvc,svc,nil]; 
[window addSubview:tabBarController.view]; 
[fvc release]; 
[svc release]; 

其中tabBarController是一個實例變量和屬性。當您的應用程序啓動時顯示的第一個選項卡將是您加載到數組中的第一個選項卡。在這種情況下,它是fvc。

希望這會有所幫助。

0

只是像往常一樣加載第一個viewController(使用它作爲主頁)並處理tabbar隱藏屬性(您想要顯示或隱藏它的位置)。