Hide UINavigationBar 3D touch - ios

I am trying to 3D peek and pop items in a UITableView. Everything works fine, except the target ViewController has a UINavigationBar which also shows.
I added my UINavigationBar to my ViewController code through Interface Builder and set self.navBar.isHidden to true which hides the UINavigationBar, but it leaves empty space equal to the size of the UINavigationBar.
Does anyone know how to hide the UINavigationBar properly?
Note: I am not using a UINavigationController, I simply added the UINavigationBar to my ViewController by drag/drop.

the target ViewController has a UINavigationBar which also shows
Use a real UINavigationController plus UITableViewController (as its root view controller). This is an excellent way to have a navigation bar even if you never intend doing any navigation.
Here's a big advantage of doing that: You don't even need to hide the navigation bar when you peek! Use the UITableViewController alone as the peek navigation controller, and the UINavigationController when you pop. Thus, the preview won't have any navigation bar but if the user presses all the way and you do the real transition, the new view controller will have the navigation bar. Remember, no law says that the peek view controller must be the same as the pop view controller!

Related

UITabBar attachment view, conform to hidesBottomBarWhenPushed

How can we attach a view to a UITabBar or UITabBarController and allow it to conform to things like "Hide bottom bar on push"? Any view that gets added to the UITabBarController will a part of the UINavigationController, meaning that the view will not take part in the tab bar animation, and will simply be left visible after a push.
Is it frowned upon to subclass UITabBar itself, and if not, how would we handle the subviews of it? My attachment is located behind the tab bar and becomes visible when needed (like Spotify's or Apple Music's player bar), which causes problems when iOS automatically moves the z-index of the tab bar during these situations.

How to change view with UITabBar (without using UITabBarController or addSubview)?

I've tried a lot to get this done.I don't want want to use addsubview or uitabbarcontroller. I want to switch the view when I tap on different tabs and tabbar should stay there. Thanks a lot in advance.I m a newbie.I want to use uitabbar not uitabbarcontroller.
A simple approach would be to wrap the view controllers you are inserting in UITabBarController in a UINavigationController then you can simply push your new view to that UINavigationController and the tab bar would be always visible!
For more details refer Apple Docs
Edit:
If you don't want to use UITabBarController then you need to do 2 things:
Add the tab bar View to UIWindow that way it would be always visible.
Scale/adjust the views in your view controllers to leave space for the tab bar

How to hide the UITabBar and show UIToolBar?

I read several answers to this question but couldn't figure out how to do it. I'm using Xcode 4.2 with ARC and no storyboards.
I'm developing an app based on the TabBar application template and extended it to contain 4 UITabBars. I'm not using UINavigationController but instead using UINavigationBar next to the status bar. When the app is loaded with the first tab shown, I have a button on the UINavigationBar and when I press it, I want to hide the UITabBar and instead show the UIToolBar at the same location where the UITabBar was located.
I tried to hide and show using the hidden property (hiding the UITabBar and showing UIToolBar). What happens is the UITabBar is hidden but the UIToolBar is shown above the location where the UITabBar was shown before. This looks ugly and I want it to be shown at the very bottom of the screen.
I think I can't use hidesBottomBarWhenPushed as I don't use a UINavigationController but instead using Navigation bar directly.
Also, I want to revert back to showing the UITabBar and hide the UIToolBar when pressing the same button on the UINavigationBar.
I am not sure if my idea would work for your scenario. Here it is...
but before, just let me tell you that hiding UITabBar, unlike hiding UINavigationBar is not animated. So to me, hiding tabBar is not a user-friendly approach, unless you create your own subclass of UITabBarController that animates hiding the UITabBar.
You can use presentModalViewController:animated and dismissModalViewControllerAnimated: methods. The viewController that is being shown modally can have a UINavigationBar, it pops out from the bottom of the screen and covers the UITabBar with animation.
Hope that helps.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html

How do I add back button to UINavigationBar programmatically?

I have a UINavigationController and when I push one of my views, I have a UINavigationBar on top that I made an ivar for and connected it. Now what I need is that button that is like half square and half arrow on the left of the bar. How would I do this programmatically? All I need it to do is say back and do my back action when it is clicked. How would I do this?
Thanks!
If you're using a UINaviationController, then each view controller that you push onto it does not need it's own UINavigationBar object set up in the nib or in code. You get it and a back button 'for free' when you push a view controller onto a navigation controller's stack.
So remove the UINavigationBar from your pushed view controller. It could actually be blocking the navigation controller's navigation bar.
If you're using a nib to set up your view controller, you can add a 'simulated element' so that you have a fake navigation bar in the nib to help lay out your UI elements.
EDIT: in Xcode 4, they're now called 'Simulated Metrics'. Set the 'Top Bar' to simulate a navigation bar in your nib.

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