解散模式vc swift之后的popviewcontroller
我想在解散modalvc之后popviewController
。但是我的代码不起作用。怎么了?
func showMessage(withTitle title: String, message: String) {
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
let alertAction = UIAlertAction(title: "ok", style: .default) { (_) in
self.dismiss(animated: true) {
self.navigationController?.popViewController(animated: true)
}
}
alert.addAction(alertAction)
present(alert, animated: true, completion: nil)
}
我也尝试过:
let controller = ViewController()
controller?.popViewController(animated: true)
I want to popViewController
after I dismiss a modalVC. However my code is not working. What is wrong?
func showMessage(withTitle title: String, message: String) {
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
let alertAction = UIAlertAction(title: "ok", style: .default) { (_) in
self.dismiss(animated: true) {
self.navigationController?.popViewController(animated: true)
}
}
alert.addAction(alertAction)
present(alert, animated: true, completion: nil)
}
I have also tried this:
let controller = ViewController()
controller?.popViewController(animated: true)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我创建了两个ViewControllers VC1和VC2。 VC1具有导航控制器,并且VC2在VC1顶部推动是导航堆栈。在VC2中,显示了警报,并在OK按钮的点击中弹出并从导航堆栈中删除。对我来说很好。
VC1的代码:
VC2的代码:
I created two viewcontrollers vc1 and vc2. vc1 has a navigation controller and vc2 is pushed on top of vc1 is the navigation stack. In vc2 the alert is shown and on tap of ok button vc2 is popped and removed from navigation stack. Works fine for me.
Code for vc1:
Code for vc2: