View Full Version : Dismissing UIAlertView without pressing button
Apr 6, 2008, 09:41 PM
How do I dismiss a UIAlertView without a Cancel or any other button being pressed?
Apr 6, 2008, 09:52 PM
I'm not sure if this is correct, but you might be able to close it by calling this:
Take a look at the docs on that (UIModalView is the superclass of UIAlertView) and see if it works.
Apr 6, 2008, 10:45 PM
Thanks! That worked.
I had read the UIModalView methods, but didn't think about calling this manually (as opposed to being triggered by the cancel button).
If anyone is interested in the code:
//Create UIAlertView alert
alert = [[UIAlertView alloc] initWithTitle:@"Alert Title" message:nil delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles: nil];
//In another function
[alert dismissWithClickedButtonIndex:0 animated:TRUE];
Apr 6, 2008, 11:12 PM
Yeah, I thought at first from reading the description (that could probably be changed a bit) that it sounded like it should be a delegate method or something, but it wasn't marked as such so might as well give it a try. Its probably set as the action for a UIControlEventTouchUpInside on the buttons when the view is created, but I can't see any side effects to calling it directly.