I read apple document about background mode
And I don't understand when should I dismiss my UIAlertView. In applicationWillResignActive:
notification or in applicationDidEnterBackground:
? And what the difference if I dismiss UIAlertView in applicationWillResignActive:
or in applicationDidEnterBackground:
?

- 5,589
- 7
- 33
- 50
-
the `-applicationDidEnterBackground:` is perfect to dismiss it, or you can use to clean up the `-viewDidDisappear:` method as well. – holex Sep 29 '12 at 06:55
1 Answers
You don't have to dismiss the alert view if your app goes into background. The UIAlertView
documentation states:
... it is up to you to decide whether to dismiss the alert view (and execute its cancellation handler) or leave it visible for when your application moves back to the foreground.
But there are many cases where it makes sense to dismiss the alert view. If a user opens your app after 2 days and the first thing he sees is an alert "Do you really want to delete this file?" he will probably not know anymore what this question is about. For such a case it is better to dismiss the alert and cancel the corresponding action when the app goes into background.
I would use applicationDidEnterBackground
(or the corresponding UIApplicationDidEnterBackgroundNotification
) for this purpose, because applicationWillResignActive
is also called for temporary interruptions such as incoming phone calls or SMS messages.

- 529,903
- 94
- 1,240
- 1,382