2016-02-26 38 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必須是模態或阻止視圖關閉的東西? –