swift 3 - how to close a last open popover on another popover?

0

I have a viewcontroller that opens a popover. This first opens a second popover. However when I give a self.dismiss on any of the popovers it is closing all popovers and the viewcontroller that called it.

I use the following commands to call each popover:

performSegue(withIdentifier: "callDriverPopupSegue", sender: self)

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
   if segue.identifier == "callDriverPopSegue" {
    let popOver = segue.destination as! CallDriverPopup
    popOver.modalPresentationStyle = .popover
    popOver.popoverPresentationController!.delegate = self
   }
}

To close use:

dismiss(animated: true, completion: nil)
    
asked by anonymous 07.11.2016 / 23:29

2 answers

0

I found a solution. With the two statements below I managed to close the popover open.

    navigationController?.popViewController(animated: true)
    self.dismiss(animated: true, completion: nil)
    
08.11.2016 / 22:06
1

I have the answer to your problem below, the scenario is different but the solution is the same. You have to write the code to close the popover in the current view controller. Writes your code in your dismissVIew method of your controler.

  • var tmpController: UIViewController! = self.presentingViewController;

    self.dismissViewControllerAnimated(false, completion: {()->Void in
        println("done");
        tmpController.dismissViewControllerAnimated(false, completion: nil);
    });*
    

Example here

    
09.11.2016 / 20:24