Reputation: 22939
The UIAlertViewDelegate
protocol states the following:
// Called when we cancel a view (eg. the user clicks the Home button). This is not called when the user clicks the cancel button.
// If not defined in the delegate, we simulate a click in the cancel button
- (void)alertViewCancel:(UIAlertView *)alertView;
However, I have a UIAlertView
that is displayed and when I now hit the Home Button in the simulator, the method alertViewCancel:
does not get called. Please note that the alertView:clickedButtonAtIndex:
delegate method gets called when I touch a button on the AlertView so the delegate is hooked up correctly.
Is this a bug on Apples side or is it me, or maybe the Simulator?
Edit:
I currently work around this issue by listening to the UIApplicationWillResignActiveNotification
notification where I do the following to dismiss the AlertView:
[self.currentAlert dismissWithClickedButtonIndex:-1 animated:NO];
[self.currentAlert release];
self.currentAlert = nil;
Upvotes: 2
Views: 1510
Reputation: 49376
It is called when the system actually cancels your alert view. Your alert view isn't cancelled anymore when your application goes into the background as unless your app is evicted by the flotsam process, when you become foreground again, your alert view will popup again. I presume, though I don't know for sure, that if flotsam kills your process, you'll get this delegate call as part of the teardown sequence.
The documentation is probably a bit misleading on this point. It used to be the case that home button presses canceled alerts, but it's not always the case any more.
Upvotes: 3