Show UITabBar while presenting a modal view - ios

When a user taps on a UITabBar item, I would like to present a view controller modally, but I would also like the UITabBar to remain visible. When the user is finished with the modal view controller I want to dismiss it modally. Basically, I want to show one view controller on top of another and dismiss the top view controller with a modal animation, while keeping the UITabBar visible. I am thinking I have to do some sort of custom animation, but I cannot figure out how to make that work.
Anyone know how to do this for iOS 6 and iOS 7?

Modal segues coverup the previous navigation controller stack, so any existing tab, navigation, and tool bar controllers will no longer accessible. You'll either need to use a push segue to retain the existing tab bar, or add a new tab bar controller to the modal view.

Related

Using Modal View Controller with UITabBarController and UINavigationBar

My application is embedded within a UITabBarController and has 4 tabs. 3 of the 4 tabs are embedded within UINavigationControllers and the other is not.
I have found if the ViewController has a NavigationBar and the I am using present view controller modally when segueing, and the presenting controller has define contextselected the modal view appears underneath both the NavigationBar and UITabBar. If define contextis not selected then the modal view is displayed above the UINavigationBar but still underneath the UITabBar. Like So,
The problem here is that because the Modal View Controller is presented underneath the UITabBar the user can still access the UITabBar and change tabs before dismissing which results in a black screen.
However if the presenting view controller has not got a UINavigationBar and has not got define context selected then the modal view controller will take up the whole view and is displayed above the UITabBar. This means the user cannot switch tabs before dismissing the modal view. Which is the intended effect I am after, however how can I achieve this when using a UINavigationBar so the user cannot switch tabs ?
If you've created your segue in a storyboard, select the segue to the modal you want to be presented over everything, and set the Presentation attribute to Over Full Screen:
If you're presenting the modal programmatically, assuming you named your view to present yourModal set the modalPresentationStyle as such:
yourModal.modalPresentationStyle = .OverFullScreen

How do you change views from a Tab Bar Controller

I am developing an app that consists of a Tab Bar Controller that points to 3 view controllers (all with tabs). In one of these tab views I've made a button and I want it to open a new view (without a tab at the bottom). This new view would need a navigation bar with a back button to return to the previous view, so I was thinking I need to create a navigation controller?
Essentially this is what I'm trying to do (I apologize for the poorly drawn diagram).
How can I get this new view (entirely independent of the tab bar controller) to display programatically? Would this require a navigation controller?
You are describing a presented view controller. Call presentViewController:animated:completion:.
I very frequently do this with a navigation bar and a Back or Done button, just as you describe. But it's not a navigation controller or navigation interface; it's just a convenient way of showing the user how to get back.
For example, this is a presented view in one of my apps. The top is a navigation bar, and the cancel button gets us back (call dismissViewController...). The rest is a scrolling view (a UICollectionView) of buttons.
[myTabBar setSelectedIndex:1]
You may have to access the tabBar like self.tabBarController so… [self.tabBarController setSelectedIndex:1];
1 is index 1 in the tabbar's stack (this is like tapping a tabBar button manually)

Tab bar disappears when trying to go back from new view

I am very new to Xcode and have encountered an issue with my app. I am trying to create a tab bar app. On one of the tabs I have a button that brings the user to a different ViewController. I want to have it so the user can select a button that would return them to the tab that had the button. I tried to set up an action from the button to the previous view (the tabbed screen), however the tab bar disappears. I hope this is makes sense.
Here is a link to a screenshot...
Easiest way to do this is to place a UINavigationController as the root view controller of the TabBarController. You can do this in storyboard by simply ctrl+dragging from the tabbar controller to the navigation controller and adding it as a relationship.
Here's an example using storyboards:
The next step is to set the third controller (in this case the table view controller) to your player view controller class.
Then, you can use the default back button and animation that comes with the navigation controller. If you prefer to hide the navigation bar at the top of the screen, then you can use your custom back button to call
[self.navigationController popViewControllerAnimated:YES];
You can also choose custom animations / segues, etc. but using a navigation controller to help you navigate screens is probably the simplest approach.

Modal Segue Into Navigation Controller with No Nav Bar

In my storyboard I have a view with a segue into a new view that's embedded into a Navigation Controller (so the segue points to the navigation controller). I have the segue set to a Modal transition, however when the new view is animating up, it contains the standard blue navigation bar above the view (which then animates out of view).
Here's what it looks like mid segue: http://i.imgur.com/3eqAQ.png
How do I make it so the modal view animates up but without the navigation bar?
I have tried hiding the navigation bar in the embedded view's init, viewWillAppear, and vieWillLoad methods and that doesn't work.
I event went so far as to create a custom subclass of UINavigationController and set the navigation controller in the storyboard to it.
Thanks!
This may sound pretty simple, but have you tried hiding the navigation bar immediately before the modal segue starts? I had this problem when presenting a modal view controller and adding a [self.navigationController setNavigationBarHidden:YES] immediately before the presentation did the trick for me.
I had almost the same problem, but I wanted to get a navigation bar for my modal transition, as it was always hidden.
There may be two ways for you to remove the navigation bar:
Make sure that your view controller is not embed in a navigation controller, as it would put one by default
Check the "Top Bar" attribute of your previous controller in the workflow and work with none/inferred values depending on your storyboard.
Regards

Hidden UINavigationController inside UITabBarController

I have an application with 5 UIViewControllers each inside a corresponding UINavigationController, all tucked inside a UITabBarController that displays 5 tabs at the bottom of the screen.
I want to display another UIViewController (inside a UINavigationController) when a dialog button is pressed.
This view should only be loaded and unloaded programatically; i.e. it should not appear in the tab bar. However, I want the tab bar to be visible always.
If I add the [UINavigationController view] to [self window] the UITabBar is covered. If I add it to any other layer, the UINavigationController adds on the compensation it has for the status bar so appears further down than expected.
A solution would be to have the 6th UINavigationController added to the UITabBar with the others, but with its tabBarItem hidden. Then I can show it and hide it using the tabBars selectedIndex property.
Accessing the tabBarItem through the UIViewController shows no obvious way of doing this.
#wisequark, I think you completely misunderstood and you have almost rewritten the architecture of my application. However I have a separate navigation controller for each view as they are mutually exclusive and there is no concept of "drilling down".
#Kendall, This is what I expect I will have to do - have the modal view appear with a hide button to bring back the normal interface. But it would be nice to keep the tab bar always visible, so I was just wondering if anyone knew of a way.
It sounds as though you have a mess on your hands. A UINavigationController is a distinct object that is very different from a UITabBarController. In general, your application should have a tab controller, one of who's tab's loads a UINavigationController which in turn loads it's views - not that both maintain management over the different views. It is also improper to refer to the display of a UIViewController as such an object doesn't have a visual representation. In the case of a UINavigationController, the navigation controller object is responsible for displaying a navigation bar and a table view (in the most common case) and for managing the display of all the views in the navigation hierarchy. It itself has no corresponding representation on screen. Similarly, a UITabBarController presents a tab bar and is responsible for the loading and unloading of the views and/or view controllers attached to the tab buttons. If we were to present this as an image, it would look something like this -
alt text http://img.skitch.com/20081112-2sqp7q4wafa34te1ga337u4k8.png
Well, it sounds like what you really want to do is present a modal view with the tab bar still visible. You could add your view as a subview of the tab bar controller's view. The tab bar's view is, oddly enough, not the tab bar itself but rather a view containing the tab bar and the selected item's view.
Alternatively, you could try calling presentModalViewController:animated: with the selected tab (i.e. [tabBarController.selectedViewController presentModalViewController:animated:]) as the receiver instead of the tab bar. I seem to recall doing this once (quite by accident) and the tab bar remained visible.
One more thought: since each of your five view controllers is a UINavigationController, you could always pushViewController:animated: onto the selected view controller, then hide the back button. Your view will just appear without animation. But you'll need to remember to pop your view controller off the stack whenever the user switches to another tab. That might take a bit more work.
The best idea I could think of would be to either push a modal navigation controller for your view (which would hide the tab bar which you do not want), or to get the tab bar controller current selected view controller (really your navigation controller for a tab) and push your new view controller on there - and then pop that view when another tab is selected with a tab bar delegate.
It seems wierd to me to push the view onto random tabs though, if the view is created from a dialog that is modal, I don't see why the view itself should not also be modal and hide tabs.

Resources