Toolbar issues with iOS 7/8 - ios

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.

Related

TableViewController scrolls under status bar

I’m working on a project in Xcode 9.1 and a very strange problem occurs with my Table View Controller.
I need to have a table view with static cells and Xcode tells me that I can achieve this only with a TableViewController (doesn’t work with a TableView in a ViewController. Gives me errors).
I’ve embedded my TableViewController inside a Navigation Controller, but when I run the project, the table View scrolls and it’s visible under the status bar (on every iPhone, from X to SE).
I wanted to make the status bar opaque but didn’t find a way to do it.
Am I doing something wrong?
My steps are:
1) Dragged a TableViewController on the storyboard
2) Embed the TableViewController into a Navigation Bar (I’ve tried also to drag the Navigation Bar directly and it comes already connected to a TableViewController).
3) Set the Cells to Static
4) Run on device or simulator.
Screenshot of my problem
Solved it!
The problem was the code I wrote to hide the navigation bar hairline (the 1px line under the bar).
Commenting the code make everything work fine.
To fix your issue I think your Navigation Bar is set to hidden.
1. In your storyboard click on the navigationBar in the navigation controller.
2. Then look for the attributes section "Drawing"
3. Check to see if hidden is true.
4. If it is uncheck it.
My setup has it set to false as default.
to hide navigation you need to write below code in viewDidLoad
self.navigationController?.isNavigationBarHidden = true

iOS - tab bar turns transparent after dismissing view controller

I have encountered a strange behaviour when using the tab bar controller in iOS. I have such a controller with 3 tabs, as can be seen on the following image:
The following problem only occurs on a physical device, not on the simulator: When I present a view controller (modal) on top and dismiss it again, the tab bar turns fully transparent (not translucent) if and only if it was presented while the map tab was active. If the list or settings tab is active when the view controller is presented, then everything stays as it's supposed to be after dismissing that view controller again.
Has anybody encountered a similar behaviour? Is it a bug? Or am I doing something wrong?
Thank you for your help.
Is this only on iPhone 4? I have had a similar bug only on 4s. There is a fix for it if that is the issue. It's an apple bug. Try in viewDidAppear in the tab controller.
- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
//Stupid fix for iPhone 4 Tab bar background becoming invisible
self.tabBar.translucent = NO;
self.tabBar.translucent = YES;
}
This worked for me to fix the background disappearing on a translucent tab bar when on iPhone 4

ios7 suddenly navigation bar height change

hi i want to solution in ios7's problem.
My classes is
AlphaViewController : UIViewController,
BetaViewController : UIViewController
when AlphaViewController will appear, Alpha's navigation bar hight is 44.0f.
looks like too. and Supported Orientation is Portrait.
then I use presentmodalViewController for BetaViewController.
BetaViewController's navigation bar will be hide in viewWillAppear.
and Supported Orientation is LandScape.
then I use popViewController function. so AlphaViewController will be appear again.
I use self.navigationController.navigationBarHidden = YES;
But suddenly Alpha's navigation bar hight is changed.
It looks like 22.0f. I don't know reason..
my english is not good.
thanks to read.
first of all presentModalViewController: is deprecated since ios6 so you may not use it for presenting an view controller.
When you present a viewController from an navigationController if you want the navigation bar to be present on AlphaViewController you dont need to hide or un hide. Since you are presenting the BetaViewController navigation bar will not appear and when you dismiss it will be visible again in AlphaViewController.

how to present a view controller on iOS7 without the status bar overlapping

I'm seeing when I migrated my app to iOS 7, the nav bar is appearing under the status bar when presenting a view controller. I think a lot of people have run into this same issue. Here's a screenshot of what I'm seeing:
Requirements:
The new view must appear "modally", i.e. I need presentViewController.
Display some sort of nav bar or toolbar, with the status bar taking on the background color of the nav bar ala iOS 7 style.
It must work on iOS 6.
I'm using a xib to handle layout, with autolayout enabled.
Options:
A. Shift your view's frame down by a bit.
Ugh, are we back to the pre-iOS 5 days and mucking with frames? Also it's generally not a good idea mixing with autolayout.
B. Add a little gap up top below your nav bar.
One disadvantage of options A and B is the status bar won't blend into your nav:
C. Programatically add constraints.
The main disadvantage is you'll have to muck with constraints and calculating the nav and status bar heights. Yuck.
D. Stretch the navigation bar / toolbar's height to include the area of the status bar.
Looks good on iOS 7, but breaks on iOS 6. You'll need to programatically update the height of the nav bar, and also make sure the rest of your view updates appropriately. Messy.
E. Mess with iOS6/7 deltas in IB.
Multiple disadvantages: You'll be hardcoding the ios6/7 deltas. Also doesn't work with autolayout.
F. Use a nested UINavigationController.
This is the workaround I selected. See answer below.
The easiest workaround I've found is to wrap the view controller you want to present inside a navigation controller, and then present that navigation controller.
MyViewController *vc = [MyViewController new];
UINavigationController *nav = [[UINavigationController alloc]
initWithRootViewController:vc];
[self presentViewController:nav animated:YES completion:NULL];
Advantages:
No mucking with frames needed.
Same code works on iOS 6 an iOS 7.
Less ugly than the other workarounds.
Disadvantages:
You'll probably want to leave your XIB empty of navigation bars or toolbars, and programatically add UIBarButtonItems to the navigation bar. Fortunately this is pretty easy.
You need to add a Vertical Constraint from your top most view to Top Layout Guide as described in the following article by Apple.
https://developer.apple.com/library/ios/qa/qa1797/_index.html
Next code worked for me. Just put it to the controller which is presenting the new controller.
#pragma mark hidden status bar
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
open you xib file and select the viewcontroller. in the inspector tab select the attributes and select in TopBar "Opaque Navigation Bar".
this solved the problem for me.

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

Resources