2011-01-20 3 views
2

誰かが私のアプリを使用していて、設定バンドルの設定を変更したとしましょう。自分のアプリに戻ってきたら、自分のビューを更新方法で設定したいと思います。私はいろいろなことを試しましたが、うまく動作しません。私のアプリが再びアクティブになったときに私のビューをリロードするには?

私のiPhoneアプリでこの種の動作を実装する最良の方法は何ですか?そして、あなたがやりたいためのフックを持っている

- (void)applicationWillEnterForeground:(UIApplication *)application { 
    /* 
    Called as part of transition from the background to the active state: here you can undo many of the changes made on entering the background. 
    */ 
} 


- (void)applicationDidBecomeActive:(UIApplication *)application { 
    /* 
    Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 
    */ 
} 

:あなたのAppDelegate

答えて

3

AppDelegateに限定されているわけではありません。 NSNotificationでコード内のどこからでもこれらのイベントを聴くことができます。 UIApplicationDidBecomeActiveNotificationを聞く方法の詳細については、this answerを参照してください。

+0

興味深いことに、通知が放棄されたことを知らなかった! –

6

は、これらのメソッドを置きます。

関連する問題