NavigationBar not appearing in second view controller - ios

i am working on iPhone app.. i am using navigation controller, but the when i am going to the second view controller i.e. to the child view controller, the navigation bar is not appearing i had tried all the solutions around. Changing the property from translucent to inferred, vice-versa, tried doing it in code in viewDidLoad, viewDidAppear, viewWillAppear, everything..
Need some help..
In simulator it is showing and working perfectly but in device it isn't. I am using iphone 4s.
Check screenshot at below location:
http://postimg.org/image/y3nzz6t79/
I wanted to use below existing Back functionality - hence the transitions:
http://postimg.org/image/r2q34a4sr/

Try to embed your second view controller with Navigation Controller.
Set Top bar property to Opaque
Add this code in ViewDidAppear
[[self navigationController] setNavigationBarHidden:NO animated:YES];

Related

Weird animated on pushing controller hiding tab bar and adding a toolbar

I have an app with the hierarchy of UITabBarController > UINavigationController > UIViewController. Currently if you tap on the collectionView's cells it performs a segue to show the full size image. I have the view controller that is being pushed setting the hidesBottomBarWhenPushed property to YES. Then in viewWillAppear: on the view controller being pushed, I am calling [self.navigationController setToolbarHidden:NO animated:NO] and as you can see in the animated below the bottom left of the screen is present from the previous screen.
Change ur code to this: Set animated YES.
[self.navigationController setToolbarHidden:NO animated:YES]
So it turns out that I had to have the view controller being pushed go under the bottom bar otherwise it gave the weird animation. When I did that everything went back to normal. I then also animated the call to setToolbaHidden:animated: as suggested above.

Remove navigation bar from main controller in Xcode?

I have a main view controller in Xcode 6 (program is in swift) on which I have a few buttons that lead to certain navigation controllers. When I test the app, the first time I see it it looks fine (without a navigation bar at the top). When I click on a button on main view controller, it shows the navigation controller I selected, everything acts perfectly again. The problem happens when I click on the bar button "back" on that nav controller in order for it to show me my main view controller again. When I'm back to the main view controller, there's a navigation bar at the top that isn't supposed to be there. I want my main view controller to have no navigation bar at the top. I tried to use push, modal and show segues to see if it might be the problem, but I still can't figure it out. Any thoughts on what might be happening?
Sounds like you need to re-hide your navigation bar. To do that, add:
self.navigationController?.navigationBarHidden = true
to the viewWillAppear of whatever view controller for which you'd like to hide the nav bar.
Updated for Swift 3:
self.navigationController?.isNavigationBarHidden = true
In mainViewController, write code to hide navigation bar in viewWillAppear method.
in Objective-C
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:YES];
[[self navigationController] setNavigationBarHidden:YES animated:NO];
}

Toolbar issues with iOS 7/8

I am having some trouble hiding toolbar (Bottom bar) on one of the view controllers in my iOS app. So I have a home view controller which has a navigation bar and a toolbar. Then a UIPageViewController is pushed (a tutorial for the app). There should be no navigation or toolbar on this screen.
I used the standard code to hide the toolbar. Here it is:
self.navigationController.toolbarHidden = YES;
It works in iOS 8 but not in iOS 7. I tried many variations and tried putting it in viewDidLayoutSubviews, viewWillAppear, viewDidappear and also right before pushing the view controller. Nothing works. Hiding navigation bar worked without issues.
Any help is much appreciated.
A better property to use when you want the toolbar hidden when pushing is setting hidesBottomBarWhenPushed to YES on the UIViewController you are pushing.

NavigationBar contents disappear on pop from view with prefersStatusBarHidden = YES

I have a fairly straightforward setup in my iPhone app, with a navigation controller and a view controller. The view controller has a title, and for most of my views, pushing other view controllers works as expected: the title is used as the label for the "back" button on the navigation bar, and the new view is shown. After the new view has been popped from the stack, the old view is shown with its title.
However, as soon as the pushed view controller implements prefersStatusBarHidden with the return value YES, the title in the navigation bar is gone after this view is popped from the stack - it remains empty and doesn't even display my custom rightbarbuttonitem.
Additionally, doing this in landscape instead of portrait does not show this behaviour - the title is displayed correctly. If you encounter this issue in portrait, you could turn the phone to landscape and back to portrait again, and the title and everything else will reappear in place.
I am unsure if this was already there in previous versions of iOS, but I am currently seeing it with iOS 8.
I had the same issue and the workaround for me was this:
In the view controller that is having prefersStatusBarHidden set to YES add:
- (void)viewWillDisappear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES];
[self.navigationController setNavigationBarHidden:NO];
}
I believe that is because prefersStatusBarHidden is a app wide setting, not per view controller.
You may be able to get around this by adding to the pushed view controllers ViewWillDisappear method
- (void)viewWillDisappear:(BOOL)animated {
[UIApplication sharedApplication].statusBarHidden = NO;
}

UINavigationController containment, iOS7 and Status Bar. Bug?

I'm updating my custom "iAD Banner Controller" to support iOS 7.
It's basically an UIViewController container composed of 3 views:
the main view (the view of the contained controller)
the banner view
a status bar background view
When the AD is available, there is an animated transition that makes the banner view and the status bar background view appear sliding from the top.
This is all managed using autolayout, and should appear like this (the status bar background is the green one, and in this case it contains an UINavigationController):
The problem is this: Using UINavigationController as the contained controller, when the banner is not visible, the nav controller extends 20px under the status bar. This is ok and expected.
But, when I move it's superview (the container) down to let the iAD banner appear, the 20px extension remains there, with this result:
However, if I do something like rotating the interface, the nav controller detects that the status bar is "far", and then adjusts itself.
I tried to call setNeedsStatusBarAppearanceUpdate and layoutIfNeeded respectively on the controller and it's view, without results.
I attach the whole project if you want to have a look: Link to the project
By now I solved using a workaround: when the AD appear / disappear I call
[self.navigationController setNavigationBarHidden:YES animated:NO];
[self.navigationController setNavigationBarHidden:NO animated:NO];
using this workaround, I force UINavigationController to detect again that the status bar is "far" and It has to recalculate the offset.
Since my view hierarchy is not so simple, and I want to re-use my AD Controller in other projects, I used a Notification to alert that the AD was appearing/disappearing.
I'll wait for other better answer a few day before marking this as correct.
Thanks

Resources