Reputation: 13
I have a alertview that starts in a view A and must stop in view B. How can I stop the alertview on B?
thks
Upvotes: 0
Views: 207
Reputation: 50697
How are you moving from A to B while a UIAlertView is displayed? Maybe post some code.
This scenario does not seem user-friendly, but there is a way you can dismiss the alert from A in B.
Create an NSNotificationCenter
and point it to a method that dismisses the alert:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dismissAlert) name:@"dismissAlert" object:nil];
And the notification should call something like the following:
- (void) dismissAlert:(NSNotification *)notification
{
[alertView dismissWithClickedButtonIndex: 0 animated: YES];
}
Now when you want to dismiss the alert, call the notification you created in View A:
[[NSNotificationCenter defaultCenter] postNotificationName:@"dismissAlert" object:nil];
Upvotes: 1