I have a table view controller with a cell that has a button.
On click of this button I am displaying a view controller as an UIPopoverPresentationController.
This pop over controller has two buttons , YES and NO.
On click of YES I want to be able to segue to another view controller and on click of NO I will dismiss the pop over controller.
On click of NO the popover gets dismissed but on click of YES I don't move to the required view controller .
Although the view did load() method of that view controller gets called. The problem is that the new view controller is not being displayed.
On click of YES,the popover gets dismissed but remains on the previous view controller
Following is my code
TableViewController class
func onTapPickButton(sender: UIButton) {
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let popoverViewController = storyboard.instantiateViewController(withIdentifier: "ConfirmDialogViewController") as! ConfirmDialogViewController
popoverViewController.preferredContentSize = CGSize(width: view.frame.width/1.33, height: view.frame.height/2.34)
popoverViewController.modalPresentationStyle = UIModalPresentationStyle.popover
let popover: UIPopoverPresentationController = popoverViewController.popoverPresentationController!
popover.sourceView = self.view
popover.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
popover.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
popover.delegate = self
present(popoverViewController, animated: true, completion: nil)
}
PopOver View controller class
@IBAction func onTapNoButton(_ sender: UIButton) {
self.dismiss(animated: true, completion: {})
}
@IBAction func onTapYesButton(_ sender: UIButton) {
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = storyboard.instantiateViewController(withIdentifier: "View") as! ViewController
present(viewController, animated: true, completion: nil)
}
Any help will be appreciated. Thank you.
In YES button action, dismiss the
popOverand in completion block present the new viewController