Search code examples
swiftxcodenavigationviewcontrolleruialertcontroller

How to show Alert after popToRootViewController


How can i show an alert in my rootviewcontroller after popping to it from another Viewcontroller higher up the hierachy?

The setup is like this:

TabbarController <- NavigationController <- ViewController <- ViewController <- Viewcontroller

self.navigationController?.popToRootViewController(animated: true)

Solution

  • You can try

    let root =  self.navigationController!.viewControllers[0]
    self.navigationController?.popToRootViewController(animated: true)
    DispatchQueue.main.asyncAfter(deadline: .now() + 0.8) {
      let alert = ///
      root.present(alert....
    }