Navigation bar with back button not hiding - ios

I have an issue with my navigation bar.
The first screen of my app is a welcome screen, with two classic buttons in the center of the screen. No bars (tab or nav, and status is hidden with the setStatusBarHidden in the viewDidLoad). I only implemented one of the buttons but both will work the same way (the two screens are similar). So the first button loads up a "sign up" screen (a UITableViewController) with a form to fill in. There, the status bar is shown, and I added a navigation bar (in the attributes panel of my view controller), with a "send" button on the top right.
In the attributes panel of my "navigation item" (as it's called), I entered a name for the back button, which is correctly displayed (although I'd like to change the name, but I'll do it later).
My problem is that when I hit the back button, it takes me back to the "welcome" screen but the status bar is not hidden, there is a nav bar with no title and no buttons, and I can't find a way to hide them. I tried using viewDidLoad, viewDidAppear, viewDidUnload (in the sign up view) but nothing works (I can hide the status bar, but the view is loaded so there is a black space between the non-hidden nav bar and my content).
By the way, I have done most of the design using the storyboard, not with code, but I don't mind using both.
Can anybody help ? Thanks.

Hide the status bar and navigation bar in viewWillAppear: method and not in the viewDidLoad: method.If your dont want to show status bar or navigation bar,put that code in AppDelegate Class.
Edited:
This will hide your navigation bar in your View controller.Put it in viewWillAppear:
self.navigationController.navigationBarHidden = YES;
This hides your status bar.
[[UIApplication sharedApplication] setStatusBarHidden:YES animated: UIStatusBarAnimationNone];
Your view controller should have wantsFullScreenLayout set to YES, as well as hiding the status bar.Black space is showing your view is automatically didn't resized when you dont have status bar or navigation bar.you need to check auto-sizing in the storyboard "size inspector" in the right side pane tabs.
Edit 1:
This will hide your bars with animation:
[self.navigationController setNavigationBarHidden:YES animated:YES];
[[UIApplication sharedApplication]setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];

Related

navigation bar states, showing and hiding the bottom nav bar

Keep in mind with the following question, I am still an iOS noob.
So I understand how to hide/show/recolor the navigation bar and whatnot. My next challenge is that some screens need the nav bar and others do not.
When my app starts off, I have the nav bar as hidden and then the user can click register or log in (both of which screens have a nav bar).
So those screens have the code to show the nav bar all while the first (welcome screen) has the code to hide the nav bar.
Here is the question: Why is it that when I first start my app, the nav bar is not there, but when I go to register/login and then hit the back button to return to the welcome page (initial page) then the nav bar is still there, even though my code to hide it is in the viewDidLoad method?
How can I fix this?
You can try moving the logic of hidding the Nav bar to the ViewWillAppear method, you just need to override it in your View Controller class.
Alternatively I would suggest to use a separate view controller to handle your login/registration screens and only use nav bars where you need them. You would have to create a view controller in your story board with your regular screens and embed the screens that need the tab bar in a navigation controller, You can then segue from your regular view controller into the navigation controller that includes your tabs.
Hope this helps

iOS Swift: Incorrect Navigation Bar Appearing

The incorrect navigation bar is appearing on my Table View Controller screen (see Storyboard Below).
I would like what's displayed on the storyboard to be my navigation bar (i.e. with "Main Feed" title and Sign Out button on the top right). However, this is what I'm actually getting -
There are two issues here: 1) The incorrect navigation bar is displaying (this one has a login back button); 2) the first few table view cells are placed underneath the nav bar vs. under it.
This happened after I embedded the Table View controller in the Tab Bar Controller. I want a bottom tab bar in the main portion of my application hence the reason why I added the Tab Bar Controller. Any suggestions on how to fix this? Rather than using the Tab Bar Controller in storyboard, is there a way to do this programatically? Thanks!
The navigation bar that you are seeing on top of the stack is the navigation bar from the UITabBarController itself, that is why you are seeing the back button show "login". There's a few ways to work around this, programmatically:
When you initialize the UITabBarController, set it's navigationController's navigation bar property to "hidden"
Go through each view controller form the beginning of your app up to where you first see this problem and in the "init" method of the viewController you are testing, set the navigationbar to hidden. Something like, self.navigationController?.navigationBar.hidden = true;
This is how you can "debug" this issue, but it's going to take some tweaking to get it right.

Xcode - replace navigation bar with toolbar on show segue

This is what I wish to do.
---- Segue : show ---->
on the destination page, I want to hide the tab bar from the previous page and show the toolbar instead.
When I check "Hide bottom bar on push" on storyboard, the tool bar on the destination page disappears as well.
I think you should change the title of your question since you want to replace the tabBar with a toolBar and keep the navigationBar. At leas this is what I understand from your sketch.
As for the question, have you tried hiding the tabBar in viewWillDisappear in your first view?

ios 6 navigation bar and status bar overlapped

The problem is like this:
My status bar is intially hidden.
I have a tab bar controller and it has a navigation controller in each of its tabs.
Screen shot is like:
Later I clicked on a button on the navigation controller's view, I would like to reveal the status bar, but it ends like this:
the navigation bar overlaps the status bar. I have to perform some actions like tapping another tab to make the navigation bar go down.
I tried to set status bar to UIStatusBarStyleBlackOpaque and it worked fine.
But if I press the "home" button on iphone to turn the app to bacground and the switch back to active, the problem occurs again if I clicked on the button.
Your status bar style is UIStatusBarStyleBlackTranslucent. You should set it to either UIStatusBarStyleDefault or UIStatusBarStyleBlackOpaque for the desired effect.
Translucent status bars overlap the full screen views, while opaque ones push those views down.
click on button, do following things:
self.wantsFullScreenLayout = NO;
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque]; //or UIStatusBarStyleDefault

Transitioning between transparent navigation bar to translucent

In Apple's recently released Remote app I noticed the way in which the navigation bar behaves is unique and I haven't been able reproduce it. When popping the Now Playing view controller the navigation bar remains transparent for the Now Playing view controller and the navigation bar for the library view controller also stays translucent (Screenshot 1). I'm trying to figure out if they are using two navigation controllers or only one. Personally I feel they're using just one for two reasons (1) the interactive pop gesture is enabled; (2) when you press the 'Now Playing' button in the library view controller, just before the now playing screen has finished 'push view controller' animation the navigation bar becomes transparent (Screenshot 2). This is the behaviour I experience when pushing my view controller (which sets the navigation bar to transparent). So my question is: How does Apple present both navigation bars of the two view controllers as if they were individual (as with Screenshot 1), even the bar buttons, navigation title etc... are 100% in opacity when switching (usually when pushing/popping the buttons and titles of the previous view controller fade as the new controller is being pushed). I've tried playing around with the bar tint colour in viewDidAppear and viewWillAppear in both view controllers but cannot reproduce the same behaviour, and cannot prevent the bar buttons from fading.
Gosh I hope I've explained this well, I get confused just thinking about it!
Screenshot 1 (Popping):
Screenshot 2 (Pushing):
I just downloaded the application to make sure. Two different navigation bars are used. You can see this by using the interactive pop gesture. Notice how the navigation bar on the bottom view controller slides in and out. During normal push and pop transitions, the navigation items just fade in and out on the existing bar, while the bar is stationary. This is what happens up until the point where the now playing view controller is pushed.
If you look quickly, during the now playing view controller animation, you can see the bottom navigation bar disappear.
From my experience with UIKit behavior and what I see in the app, here is what I think happens:
album_vc = the bottom, list view controller
nowplaying_vc = the top view controller
On nowplaying_vc's viewWillAppear:
Set the navigation bar to hidden using [self.navigationController setNavigationBarHidden:YES animated:YES];. Since this is in animation block, this will make the navigation bar slide out during the push animation.
Set [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent; Pretty sure about this, because notice there is no animation in the transition of the status bar styles. It just becomes white.
On nowplaying_vc's viewWillDisappear:
Set the navigation bar to shown using [self.navigationController setNavigationBarHidden:NO animated:YES];. Since this is in animation block, this will make the navigation bar slide in during the pop animation.
Set [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault; Again, notice how during interactive pop gesture, the status bar just changes with no animation.
To achieve the transparent look of the navigation bar of nowplaying_vc, you can use an empty image ([UIImage alloc]) with setBackgroundImage:forBarPosition:barMetrics:.
Since the application does not rotate, we can't be sure if the navigation bar on nowplaying_vc is part of another navigation controller or just a navigation bar on the top with a position of UIBarPositionTopAttached. For all we know, there isn't even a navigation bar there but just a back chevron image view (back bar button is comprised of an image view and a button).
I think the status bar style is changed in viewWillAppear: and viewWillDisappear: due to the unnatural feel there is during interactive pop gesture. I would recommend using an animated transition, or even better, use the new view controller-based status bar style, which the system animates transitions by itself.
Update for modern API:
You should use the animateAlongsideTransition:completion: or animateAlongsideTransitionInView:animation:completion: API, rather than relying on the implicit animations of viewWillAppear: and viewWillDisappear:.
Instead of hiding and showing the navigation bar, you can update the alpha for the navigation bar. It will animate smoothly during the transition. For the view controller with transparent nav bar, instead of modifying the nav bar, create a navbar (or just the back button and title etc.) manually in the second controller's view. We will then hide the navbar when transitioning from first view controller to the second one.
On your first controller's viewWillDisappear and on your second view controller's viewWillAppear:, set the navigation bar alpha to zero using self.navigationController.navigationBar.alpha = 0;. Since this is in animation block, this will make the navigation bar disappear during the push animation.
Set the alpha back to one in first controller's viewWillAppear and second controller viewWillDisappear.

Resources