Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

swift dismiss modal and push to new 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)

            })
}
like image 866
Pan Mluvčí Avatar asked Jan 08 '23 03:01

Pan Mluvčí


1 Answers

You should create a protocol

protocol View1Delegate: class {
    func dismissViewController(controller: UIViewController)
}

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

    }
}

You can do anything in here. Push screen you want. Detail implement you can see my demo: Demo Push View in Swift

like image 70
vien vu Avatar answered Jan 15 '23 08:01

vien vu