1

这是按调用顺序排列的代码。UIAlertView当这段代码被调用时,屏幕上会出现A :

[upcAlertView dismissWithClickedButtonIndex:0 animated:YES];

[self.navigationController pushViewController:editController animated:YES];

问题是出现时UIAlertView不会从屏幕上删除editController。我需要这些事情发生,因为我有一些加载正在进行,viewWillAppear所以editController我想添加一个快速进度轮(但我需要对话框消失)。这段代码是从主线程调用的。

任何人有任何见解?

4

3 回答 3

3

查看UIAlertViewDelegate文档,更重要的是方法

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex;

调用此方法时,您可以推送视图控制器,以便您知道它在推送之前已被解除。

像这样:

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
    [self.navigationController pushViewController:editController animated:YES];
}
于 2013-06-05T18:35:43.147 回答
0

您的 UIAlertView 是否符合UIAlertViewDelegate协议?

您将需要更新您的:

.h 文件

@interface YourClass : YourClassSuperClass <UIAlertViewDelegate>

.m 文件

UIAlertView *alert = //alloc init
[alert setDelegate: self];

添加此方法:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
   switch (buttonIndex)

    case(0):
    {
      //Cancel button
    }
      break;

    case(..n):
    {
      //All other buttons
    }
      break;

    default:
    {
      //should never be thrown
    } 
     break;
}
于 2013-06-05T18:40:41.640 回答
0
check uialerview delegate  UIAlertViewDelegate 
Sent to the delegate when the user clicks a button on an alert view.
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
}
//Sent to the delegate after an alert view is dismissed from the screen.
alertView:didDismissWithButtonIndex:
{
}
于 2013-06-05T19:50:38.137 回答