迅速解散模态并推送到新的VC [英] swift dismiss modal and push to new VC
本文介绍了迅速解散模态并推送到新的VC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有tableview ... 1个表,显示一个新的模式窗口,当我按下按钮时,我想关闭模式窗口并按下VC.我的代码仅隐藏模式视图,但不进行推送.
I have tableview... 1 table showing a new modal window and when I press the button I want to dismiss the modal window and push to VC. My code only hide the modal view but no push is made.
@IBAction func registrationBtn(sender: AnyObject) {
let openNewVC = self.storyboard?.instantiateViewControllerWithIdentifier("registrationVcID") as! RegistrationVC
self.dismissViewControllerAnimated(false, completion: { () -> Void in
self.navigationController?.pushViewController(openNewVC, animated: true)
})
}
推荐答案
您应该创建一个协议
protocol View1Delegate: class {
func dismissViewController(controller: UIViewController)
}
当您点击注册"上的按钮时,将把代表回叫到TableView. TableViewController应该实现:
When you tap button on Register will call delegate back to TableView. TableViewController should implement:
func dismissViewController(controller: UIViewController) {
controller.dismissViewControllerAnimated(true) { () -> Void in
//Perform segue or push some view with your code
}
}
您可以在这里做任何事情.推送您想要的屏幕.您可以查看我的演示的详细工具:在Swift中进行演示推送视图
You can do anything in here. Push screen you want. Detail implement you can see my demo: Demo Push View in Swift
这篇关于迅速解散模态并推送到新的VC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文