swift – 如何从UIAlertController的UIAlertAction处理程序中解除UIViewController?

swift – 如何从UIAlertController的UIAlertAction处理程序中解除UIViewController?,第1张

概述我想向用户提供一个简单的UIAlertController,其中一个选项触发关闭父视图控制器.这是我正在使用的代码: let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert) alert.addAction(UIAlertActio 我想向用户提供一个简单的UIAlertController,其中一个选项触发关闭父视图控制器.这是我正在使用的代码:
let alert = UIAlertController(Title: Title,message: message,preferredStyle: UIAlertControllerStyle.Alert)    alert.addAction(UIAlertAction(Title: "Close VIEw",style: UIAlertActionStyle.Destructive,handler: {        action in        self.dismissVIEwControllerAnimated(true,completion: nil)    }))    alert.addAction(UIAlertAction(Title: "CANCEL",style: UIAlertActionStyle.Cancel,handler: nil))    self.presentVIEwController(alert,animated: true,completion: nil)

它没有任何影响.执行“关闭视图”处理程序后,显示警报的视图控制器仍然存在.

我还在UIAlertAction *** 作块中尝试了self.navigationController?.dismissVIEwControllerAnimated(true,completion:nil),但这也无效.

运用
self.navigationController?.popVIEwControllerAnimated(true)

代替

self.dismissVIEwControllerAnimated(true,completion: nil)

根据需要工作并关闭显示警报的视图控制器.

总结

以上是内存溢出为你收集整理的swift – 如何从UIAlertController的UIAlertAction处理程序中解除UIViewController?全部内容,希望文章能够帮你解决swift – 如何从UIAlertController的UIAlertAction处理程序中解除UIViewController?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1042797.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-24
下一篇2022-05-24

发表评论

登录后才能评论

评论列表(0条)

    保存