10

そのため、今後の iPhone アプリでアプリの切り替えをサポートしたいと考えており、アプリケーション デリゲートに適切なデリゲート メソッドをすべて実装しました。そのため、ユーザーがアプリケーションを再開すると、NSLog などでユーザーのアクティビティを確認できます。ただし、アプリがコントローラーを再開したことをどのように確認できますか? アプリがそのコントローラーで再開したことを通知するためにコントローラーに入れることができる方法はありますか? 私が尋ねる理由は、私のアプリケーションが独自の URL スキーマを処理し、起動された URL に応じてビューを更新したいからです。どんな助けでも大歓迎です。

前もって感謝します

4

3 に答える 3

20

UIApplicationWillEnterForegroundコントローラーに通知を監視させることができます。おそらく次のようになります。

- (void) viewDidLoad
{
    [super viewDidLoad];
    //do stuff here
    if(&UIApplicationWillEnterForegroundNotification) { //needed to run on older devices, otherwise you'll get EXC_BAD_ACCESS
        NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
        [notificationCenter addObserver:self selector:@selector(enteredForeground:) name:UIApplicationWillEnterForegroundNotification object:nil];
    }


}
- (void)enteredForeground:(NSNotification*) not
{
    //do stuff here
}
于 2010-08-21T01:53:18.490 に答える
-2

You can also just override - (void)applicationDidBecomeActive:(UIApplication *)application in the app delegate to have it do whatever you want it to do when it comes back from the background. If you want a particular view to get the message rather than the app delegate you need to register for the notification as described by Elfred above.

于 2010-08-23T15:33:45.943 に答える