2016-02-26 41 views
0

在备份过程结束时,我想让用户知道备份已完成。我曾经使用UIAlertView,它工作。然而,它的贬值,所以换了UIAlertController这些。弹出消息完成后,窗口关闭。新的UIAlertController在这种情况下似乎不起作用。我究竟做错了什么?UIAlertController doesnt popup

这种情况正在发生,视图关闭之前的过程结束。下面代码中的最后一行是关闭视图。 UIAlertView必须是模态或阻止视图关闭的东西?

我曾经使用这个代码,它工作得很好。

UIAlertView *myalert = [[UIAlertView alloc] initWithTitle:nil message:Msg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; 

     [myalert show]; 

    [self presentViewController:alert animated:YES completion:nil]; 

,你不要这个新的代码中看到的任何东西

UIAlertController * alert= [UIAlertController 
            alertControllerWithTitle:@"" 
            message:Msg 
            preferredStyle:UIAlertControllerStyleAlert]; 

    UIAlertAction* okButton = [UIAlertAction 
           actionWithTitle:@"OK" 
           style:UIAlertActionStyleDefault 
           handler:^(UIAlertAction * action) 
           { 

            [alert dismissViewControllerAnimated:YES completion:nil]; 

           }]; 


    [alert addAction:okButton]; 



    [self presentViewController:alert animated:YES completion:nil]; 



    [self dismissViewControllerAnimated:NO completion:nil]; 
+3

警报的看法? [self dismissViewControllerAnimated:NO completion:nil]; –

+0

标记答案问题已解决 –

+0

这种情况正在发生,视图关闭之前的过程结束。下面代码中的最后一行是关闭视图。 UIAlertView必须是模态或阻止视图关闭的东西? –

回答

1

这行看起来错误:

[self dismissViewControllerAnimated:NO completion:nil]; 

尝试移除或将其地方更适合。我建议你立即提出并解散警报。

+0

这正在发生,视图关闭之前的过程结束。下面代码中的最后一行是关闭视图。 UIAlertView必须是模态或阻止视图关闭的东西? –

1
[self dismissViewControllerAnimated:NO completion:nil]; 

当您显示警报并快速关闭显示警报的视图时删除此行。

总之你是显示警告,并取消对哪些你为什么加入这条线被证明

+0

这种情况正在发生,视图关闭之前的过程结束。下面代码中的最后一行是关闭视图。 UIAlertView必须是模态或阻止视图关闭的东西? –