0
votes

I'm trying to create a functionality in an iOS app that is similar to Instagram's camera "TabBarItem" functionality. When the camera button is pressed, the tabBarController dismisses itself (modally) and a camera view is displayed in the background. When we decide to dismiss the camera view, the tabBarController is presented modally and all is good! My question is similar to this implementation.

I have a customized UITabBar where 2 "TabBarItems" should perform the action described above. So when one "TabBarItem" is pressed, the tabBarController should dismiss (modally) and a View should be present in the background as the tabBarController is being dismissed. The same should happen with the other "TabBarItem" but with a different view showing up. I've thought of a couple different methods of doing this but none of them seem really "elegant" and I haven't found a similar question on SO. So here goes.

For the purposes of describing it easier:

TabBarItem1 (TB1) is pressed -> TabBarController dismisses (modally) -> ViewController1 (VC1) is shown (as TabBarController is being dismissed)

TabBarItem2 (TB2) is pressed -> TabBarController dismisses (modally) -> ViewController2 (VC2) is shown (as TabBarController is being dismissed)

1st Method: Set VC1 as the initialVC -> present VC2 modally (animated:NO) -> which presents TabBarController modally Then, when... TB1 pressed -> Dismiss TabBarController (animated:YES) -> Dismiss VC2 (animated:NO) PROBLEM: VC2 will be visible until TabBarController is dismissed. So this is a no go.

2nd Method: Create a ViewController (which is set as the initialVC) that contains 2 UIViews (representing VC1.view & VC2.view) that are hidden/displayed based on the TabBarItem selected. This SEEMS like the most reasonable solution. But I don't think this is very elegant. I was wondering if anyone had any suggestions. Hopefully, it's not as confusing as I made it seem.

Any help would be appreciated.

1

1 Answers

0
votes

If you do method #1 and dismiss VC2 (without dismissing the tab bar yourself first) does dismiss both in the stack with the correct appearance? I haven't kept up with the modal stack documentation, but I think that might work.

You may have a little cleanup to do when you need to put the tab bar back (although I think it should return when you re-present vc2.)