dismiss UIAlertController presented by a modal view controller

回眸只為那壹抹淺笑 提交于 2019-12-05 05:51:06

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

You don't need to dismiss or remove the UIAlertController manually in any way in a button handler - it does that itself.

Just remove the call to dismissViewControllerAnimated:completion:.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!