0

Storyboard

As you can see, my navigation controller is embedded in the root view controller. In this view controller, I have a subview, and at one point, I push the popover onto the view controller. For some reason, I cannot use navigationController.popViewController(animated: true) because the navigation controller is nil(by printing the value to the debug console). How can I fix this?

Ashley Mills
  • 50,474
  • 16
  • 129
  • 160
Xcoder
  • 1,433
  • 3
  • 17
  • 37

2 Answers2

1

Use dismiss(animated flag: Bool, completion: (() -> Void)? = nil). Call it from your popover view controller:

self.dismiss(animated: true) 
ielyamani
  • 17,807
  • 10
  • 55
  • 90
0

if you present your popover from ViewController

self.present(popover, animated: true, completion: nil)

you can dismiss it in popover

self.dismiss(animated: true) 

and if you push your popover to your navigation controller by

self.navigationController?.pushViewController(popover, animated: true)

you can dismiss your popover using

self.navigationController?.popViewController(animated: true)
Anton
  • 111
  • 10