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.