iPhone app entering background state and presenting a UIAlertView
If an app delegate receives the -willResignActive
message a开发者_开发知识库nd a UIAlertView is within 0.5 seconds of being shown, the app will present two alert views (one a duplicate) when it becomes active once more.
This is a problem, because if responding to the first alert view means there are no responders to the duplicate (likely!) the app will just crash.
Thoughts?
The best solution I have is to retain a static reference to a UIAlertView, dismiss (with clicked button index -1), release, and then allocate/init a new instance at the same address. This makes sure there's only ever one alert view scheduled or showing. If an alert view is already showing, ignore (or manage) the new request (failsafe popping to root view or some such).
It's not very satisfactory because UIAlertView
s have nothing to do with the workings and shouldn't be static. In my mind at least.
精彩评论