7

我假设我需要实现:

[[NSNotificationCenter defaultCenter] addObserver:self 
                                                 selector:@selector(resignActive:)
                                                     name:UIApplicationWillResignActiveNotification
                                                   object:nil];

但不确定这是否是确定我的应用程序即将离开活动状态的正确通知。

这是取消网络连接以及应用程序终止的好地方吗?

4

1 回答 1

11

存在UIApplicationWillResignActiveNotification发送但应用程序不进入后台的情况,例如,如果收到呼叫但用户选择不接听。

用于UIApplicationDidEnterBackgroundNotification在进入后台时收到通知。UIApplicationWillEnterForegroundNotification请注意,如果再次快速打开应用程序,有时会发送此信息。

于 2010-07-29T16:56:27.180 回答