大佬教程收集整理的这篇文章主要介绍了ios – 使用UIAlertAction关闭视图控制器,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
视图控制器位于导航控制器内,是堆栈中的第二个.
我想出了以下代码:
@IBACtion func logout() { let logoutAlert = UIAlertController.init(title: "Log out",message: "Are you sure ?",preferredStyle:.Alert) logoutAlert.addAction(UIAlertAction.init(title: "Yes",style: .Default) { (UIAlertAction) -> Void in //Present entry view ==> NOT EXECUTED self.dismissviewControllerAnimated(true,completion:nil) }) logoutAlert.addAction(UIAlertAction.init(title: "Cancel",style: .Cancel,handler: nil)) self.presentViewController(logoutAlert,animated: true,completion: nil) }
self.dismissviewControllerAnimated(true,completion:nil)行被读取,但它没有做任何事情.
logoutAlert.addAction(UIAlertAction.init(title: "Yes",style: .Default) { (UIAlertAction) -> Void in self.navigationController?.popViewControllerAnimated(true) })
不幸的是,popViewControllerAnimated似乎没有提供一种方法来附加你自己的完成处理程序开箱即用.如果你需要一个,你仍然可以通过利用相关的CAtransaction添加一个,它看起来像这样:
logoutAlert.addAction(UIAlertAction.init(title: "Yes",style: .Default) { (UIAlertAction) -> Void in CAtransaction.begin() CAtransaction.setCompletionBlock(/* YOUR BLOCK GOES HERE */) self.navigationController?.popViewControllerAnimated(true) CAtransaction.commit() })
以上是大佬教程为你收集整理的ios – 使用UIAlertAction关闭视图控制器全部内容,希望文章能够帮你解决ios – 使用UIAlertAction关闭视图控制器所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。