2011-08-06 56 views
0

我使用TabBarController,它在我的iPod中工作正常。TabbarController在3.0崩潰

但我的應用程序崩潰3.0。請幫忙嗎?

self.window.rootViewController = self.tabBarController; //crashing here 

和日誌顯示

-[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x127c80 
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -  
[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x127c80' 
+0

根據例外情況,您想要設置爲rootview控制器的值不是初始化的,也不是NULL。 –

+0

亞,但它在我的iPod中運行良好,僅在3.0崩潰。 – PJR

+0

實現NSZombieEnabled = YES,它會告訴你確切的崩潰原因。 –

回答

2

This可能會告訴你正確的方向。讓我知道如果問題仍然存在。

由於在不同版本的iOS上執行,該方法可能已被棄用。

2

崩潰是因爲您調用的方法不存在,而不是因爲您的變量未初始化。

-setRootViewController在iOS 4.0之前不存在。使用

[self.window addSubview:self.tabBarController.view]; 

代替。

或者,將您的目標平臺更新到4.0.2或更高版本。在這一點上,可能不到5%的用戶不使用iOS 4。