gpt4 book ai didi

ios - UIAlertController 不弹出

转载 作者:行者123 更新时间:2023-11-28 21:31:53 27 4
gpt4 key购买 nike

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

这正在发生,并且在 View 关闭之前流程结束。下面代码的最后一行是关闭 View 。 UIAlertView 必须是模态的还是阻止 View 关闭的东西?

我曾经使用过这段代码,效果很好。

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

最佳答案

这一行看起来不对:

[self dismissViewControllerAnimated:NO completion:nil];

尝试删除它或将其放在更合适的地方。我建议您立即呈现然后解除警报。

关于ios - UIAlertController 不弹出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35658650/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com