Search code examples
iosswiftuitabbarcontrollermodalviewcontrollerpresentmodalviewcontroller

Prevent Dismissal of Modally Presented ViewController


I am presenting a viewcontroller modally and am trying to configure it where, when I re-enter the foreground after going to the background (i.e. I click a website link that redirects me out fo the app and then I navigate back to the app), I don't want the presented viewcontroller to be dismissed.

Is the only option to create a navigationcontroller stack? Hoping for a solution without this, and I couldn't find any existing commentary around this/am fairly new to all this. Any advice would be helpful.

My view hierarchy is...

  1. Root MainTabBarVC

  2. Load DummyMenuVC into MainTabBarVC viewcontrollers

  3. Present on shouldSelect tabBarControllerDelegate method RealMenuVC

  4. Tap RealMenuVC Button to present NextVC

I have #2 & #3 to be able to interact with the menu over the full context of any tabBarItem selected.


Solution

  • Learned a presented vc isn't dismissed just because it goes into the background mode, and that something must have been programmatically integrated to trigger it.

    I traced my issue to a notificationCenter observer I had included, which invoked a function that dismissed presented vcs.