I had developed an app earlier for ios 4 and above, in which I had used 2 navigation bars on top. 1 was a global bar common for all the views and the other changed with the views.
In IOS 7 the main nav bar is overlapping the navigation bar of the views.
If I change the position or any other attribute of the navigation bars it renders the views blank.
Is there a way that I can have the view navigation bar below the main navigation bar like it appears in IOS 6?
Thanks in Advance
Moiz Ahmed Sulaiman
Did you try to set dgesForExtendedLayout for your VC:
self.edgesForExtendedLayout = UIRectEdgeNone;
or change your navigationBar translucent?
navigationBar.translucent = NO; // It is YES by default in iOS7.
Related
Hi I am developing small Iphone application in which I am giving colour for my navigation bar like this
[self.navigationController.navigationBar setTranslucent:NO];
[self.navigationController.navigationBar setBarTintColor:[UIColor redColor]];
But because of this my status bar also become of red colour. I want to change it to white. I tried in followings way but those are not working for me.
in info.plist file I set View controller-based status bar appearance = "NO"
then in application:didFinishLaunchingWithOptions: set [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
Then in UIViewcontroller
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
But above methods are not working for me. My navigation bar and status bar of same colour. I want to make status bar colour to white. My application is very simple having one UIView controller with one navigation controller. Am I doing some thing wrong? Need Help. Thank you .
UIStatusBarStyleLightContent tells the status bar to display light colored text, but it is still transparent. And because the navigation controller reports the position of its navigation bar to be UIBarPositionTopAttached, you see the effect of the navigation bar's color stretching beneath the status bar.
Here are two ideas how to achieve what you are looking for:
Subclass the navigation controller, implement - (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar and return UIBarPositionTop. This make the navigation bar not stretch beneath the status bar, and instead the superview of the navigation bar (which is usually white), will show.
Or, better, subclass the navigation controller, add a subview of 20pt height above the navigation bar, and in viewDidLayoutSubviews, position and resize the subview correctly to orientation. Now you can give any color you'd like to this view, and it will be the color of the status bar.
Edit: Based on the comments, the positionForBar: approach may not work.
I have a problem with a UISearchViewController (using a storyboard layout).
My main view controller has a navigation bar at the top, beneath which I have positioned the UISearchBar. A MKMapView extends below the search bar and navigation bar.
When the SearchViewController is active, the Navigation Bar slides up. I have added an autolayout constraint to stick the uisearchbar to the bottom of the nav bar. However, the search bar doesn't appear to extend beneath the status bar and above the map view. Instead the mapview appears in a 20px gap above.
Any help would be greatly appreciated!
Setting translucent to false on my navigation bar did not fix this. However setting the translucent property of my searchBar worked for me.
I used these UISearchDisplayDelegate methods to change the value depending on whether the searchBar is active or not.
func searchDisplayControllerWillBeginSearch(controller: UISearchDisplayController) {
// self.searchBar is an IBOutlet from storyboard
self.searchBar.translucent = false
}
func searchDisplayControllerWillEndSearch(controller: UISearchDisplayController) {
self.searchBar.translucent = true
}
I think it can be fixed with navigationBar.translucent = NO; It is set to YES by default in iOS 7. Had a lot of trouble with that myself.
Try this in info.plist file to disable the status bar
I'm testing my application with iOS7 and I have an issue with status bar. Basically the status bar appear over navigation bar like the image below:
I try to call in my viewDidLoad
self.edgesForExtendedLayout = UIRectEdgeNone;
self.automaticallyAdjustsScrollViewInsets = YES;
without success.
I have also added to the info.plist file UIViewControllerBasedStatusBarAppearance with no luck.
The main problem is that the application must be compatible with iOS6 and iOS7 and currently on iOS7 the view shifted 20px from the top.
edgesForExtendedLayout and automaticallyAdjustsScrollViewInsets are just standards for how parent view controllers lay out / manage the view. It looks like you're using a UINavigationBar, but not a UINavigationController, which means these properties won't do anything unless you code them to.
You can switch to use a UINavigationController, or you can programmatically change the height of your UINavigationBar from 44 to 64 on iOS 7.
Add an outlet to the UINavigationBar.
float currentVersion = 7.0;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= currentVersion) {
// iOS 7
self.navBar.frame = CGRectMake(self.navBar.frame.origin.x, self.navBar.frame.origin.y, self.navBar.frame.size.width, 64);
}
You can also hide the status bar, this might be a better approach on these views to get more screen real estate.
I answered that here:
Position of navigation bar for modal view - iOS7
This is the biggest issue that comes with iOS 7 and there are many solutions to solve this but in my opinion, the best way to solve is to remove the navigation bar and embed your view controller in a navigation controller by going to Editor > Embed In Navigation Controller.
Add constraints top space to top layout guide
How to set the position of a Navigation Bar programmatically? Autolay have been turned off as its causing issues in other IOS. Cheers guys.
[my layout]
View Controller
View
Toolbar
WebView
Navigation Bar
Nav Item
First Responder
Exit
Navigation bar is currently appearing at the bottom of the screen not the top where I want it.
Try this
[self.navigationController.navigationBar setFrame:CGRectMake(x,y,width,height)];
If you are using Interface Builder you can simply drag the navigation bar to where you want it
I'm pretty new in iphone programming and have stumbled upon this issue which I guess should be pretty basic stuff.
I am using a tab bar application created from a template in XCode IOS 5.1. It works fine and creates 3 screens in the storyboard (tab bar controller + + 2 descended views) but when I try adding a top bar to these 2 views there is a problem...
I do this by adding the top navigation bar in interface builder from object inspector for the tab bar controller. After ticking this option the top bar shows perfectly in my storyboard for all 3 screens (tabbarcontroller + 2 descended views) but after I run the project the top navigation bar is no longer there.
What am I missing here? Why is there no top bar?
If you want to show a navigation bar on two ViewControllers of your tab bar based application, then you can do as follows:
Delete the viewcontroller1, then drag ViewController into storyboard from library and select it and go to Editor\Embed In\Navigation Controller.
From the UITabBarController, click on tabbar and right click, select relationship and drag it to the navigation controller. (means add the UINavigationController as a tab).
Hope this helps!
follow as Nuzhat Zari to show navigation bar on viewcontrollers of your tabBar based application
self.tabBar.frame =CGRectMake(0,0,self.view.frame.size.width,50);
This will make Tab Bar to appear at the top of controller.