0

I have a Swift Tab Bar with 3 Bar Items which lead to 3 different ViewControllers, A, B and C. I'm not using any NavigationControllers. A leads to A1 ViewController via :

self.definesPresentationContext = true
A1viewcontroller.modalPresentationStyle = .overCurrentContext
self.present(A1viewcontroller, animated: true, completion: nil)

And the A1 has a Back button that dismisses itself to return to A via:

self.dismiss(animated: true, completion: nil)

My problem is that if I click through to show A1 from A, then click on the Tab Bar Item for B, then go back to the A Tab Bar Item which shows me A1 where I left off and I click on the Back button I get a black screen where I would have expected to go back to the presenting viewcontroller A. If I then click back again to B, then back to the A Tab Bar Item I see A which is as if the A1 viewcontroller did get dismissed.

So when I'm on A1 why does going to B mess up the Back button action when I return to A and send me to a black screen?

By the way, I have read through: modal View controllers - how to display and dismiss

Paul K.
  • 67
  • 1
  • 12
  • The link to the duplicate was very helpful. Thank you. The answer there works in that it disables the user from switching to other tab bar items. That is great until the user has completed whatever task (or decided to cancel the task) of the current tab bar item. Then how do you reactivate the tab bar so that the user may go to other tab bar items? I tried to put this comment on that question and answer but it is closed to any new comments. – Paul K. Nov 08 '18 at 17:28
  • I was hoping that I misread the instructions and put the code in the wrong ViewController Class so I tried putting the code into the 'final' A1 ViewController Class but that didn't disable the tab bar. It seems like it needs to go into the A ViewController Class but then that disables the tab bar once the user goes to that tab bar item for the first time. – Paul K. Nov 09 '18 at 18:59
  • I found a better solution to this and it has to do with turning the individual BarItems enabled field to false on viewDidAppear. See here: https://stackoverflow.com/questions/45318008/swift-3-tab-bar-disable-tab?rq=1 – Paul K. Nov 10 '18 at 15:05

0 Answers0