且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

解雇由模态视图控制器呈现的UIAlertController

更新时间:2023-02-16 11:20:25

不要在按钮处理程序中调用 self dismissViewController 。这特别声明您希望视图控制器被解除。

Don't call self dismissViewController in the button handler. That specifically states that you want the view controller dismissed.

您无需关闭警报。它会自动解散自己。您应该在按钮处理程序中执行的唯一操作是执行您需要的任何操作。如果您不需要做任何事情,请不要做任何事情。

You don't need to dismiss the alert. It will automatically dismiss itself. The only thing you should do in the button handler is perform whatever action you need. Do nothing if you don't need to do anything.

如果您的提醒只是一条消息,而您不需要执行任何操作,请执行以下操作:

If your alert is simply a message and you don't need to perform any action, just do this:

UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];