2

I have a set of detail views that are intended to be accessible via multiple Tab Bar controllers. The main goal here is to make a particular set of tabBar items available based on some conditions of a particular item in the table.

My current approach to this is two tabBar controllers connected to the set of detail views. Tapping a cell triggers a performSegueWithIdentifier to bring the user to the proper tabBarController and thus, allows access to the correct set of viewControllers.

Two Tab Bar controllers with common views

Unfortunately, this produces unusual results. Depending on the specific views in each tabBar and whether or not the view is present in one or both tabBars, the view could either a) load properly with all intended views functioning as expected. b) not load all the intended views (usually only one of them) or c) load the expected navigation controller (which this is all nested in) but with a black screen and no tabBar controller. This behavior differs independently on each of the two tabBars.

How can the desired end-result be accomplished without these errors? (please provide answers in Swift) Ideally, I would like to use a single tabBar controller and conditionally show a given set of views accessible by the tabBar.

Michael Voccola
  • 1,827
  • 6
  • 20
  • 46
  • In the document "Tab Bar Controllers", Apple lists the only ways that a tab bar controller should be used, and embedding it in a navigation controller is not one of them. That could be your problem. Try presenting them modally instead, and see if that makes a difference. – rdelmar Feb 10 '15 at 02:28
  • Thanks rdelmar, but presenting modally did not change the behavior. Achieving this concept must be possible - it can't be that one needs to duplicate a view in Storyboard to solve this scenario. – Michael Voccola Feb 10 '15 at 02:52
  • Yeah, I wouldn't think you would need to duplicate the controllers, since each tab bar controller should be instantiating it's own copy of the controller that looks like it's shared. It would be easy enough to try that though -- you can copy and paste a scene in the storyboard (the new one appears right over top the old one, so you won't see it until you drag it off). – rdelmar Feb 10 '15 at 02:57

0 Answers0