开发者

UIAlertview in 2 view

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


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.

View A

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];
}

View B

Now when you want to dismiss the alert, call the notification you created in View A:

[[NSNotificationCenter defaultCenter] postNotificationName:@"dismissAlert" object:nil];


Use dismissWithClickedButtonIndex:animated:

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜