2010-11-20 44 views
3

嘿,我在模擬器中嘗試多任務(我只有第二代iPod和iPad),我仍然有一些問題。我的測試方法是這樣的:applicationWillEnterForeground從來沒有叫

- (void)applicationDidBecomeActive:(UIApplication *)application { 
NSLog(@"Entering %s",__FUNCTION__); 

if (enteredFromBackground) { 
    NSLog(@"Entering from Background"); 
    enteredFromBackground = NO; 
} 
} 

- (void)applicationWillEnterForeground:(UIApplication *)application { 
NSLog(@"Entering %s",__FUNCTION__); 

enteredFromBackground = YES; 
} 

Unforntunately,我沒有看到從applicationWillEnterForeground的NSLog的,這就是爲什麼我添加了線來表示我applicationDidBecomeActive東西。 我得到的是

2010-11-20 15:58:12.796 iBeat[45997:207] Entering -[AppDelegate_Shared applicationDidEnterBackground:] 
2010-11-20 15:58:18.160 iBeat[45997:207] Entering -[AppDelegate_Shared applicationDidBecomeActive:] 

回答

5

最後我發現我的問題! 由於我有一個通用的應用程序,我有一個Appdelegate_Shared,一個Appdelegate_iPhone和一個Appdelegate_iPad。 我有兩個子類中的「applicationWillEnterForeground」的空實現,但沒有調用超級!

然後,我不知道爲什麼在Appdelegate_Shared方法從來沒有得到所謂的o.O

1

我不認爲我能解釋這個任何優於:

http://www.drobnik.com/touch/2010/07/understanding-ios-4-backgrounding-and-delegate-messaging/

我結束了剛剛關閉的多任務處理我的第一個應用程序。

+0

好吧,老實說,我讀了三遍,我認爲它還是它的方式是在WWDC教訓解釋。因此,在應用程序返回到前臺之前應調用「applicationWillEnterForeground」方法。我正在建立對4.1,我沒有選擇退出,我只是不明白什麼是錯的。我的意思是我得到了「applicationDidEnterBackground」,那爲什麼不當我回來呢? – Bersaelor 2010-11-26 01:05:32