Hide statusbar with UINavigationBar barPositionTopAttached - ios7

I have rootViewController - UINavigationController.
As you know UINavigationController has UINavigationBar.
In iOS 7 UINavigationBar could be with barPosition topAttached.
I want to hide ON/OFF statusBar by clicking on button. But I also want that UINavigationBar should be always barPositionTopAttached.
- (BOOL)prefersStatusBarHidden {
return __statusBarHidden;
}
- (IBAction)tapShowPhotosButton:(id)sender {
__statusBarHidden = !__statusBarHidden;
[self setNeedsStatusBarAppearanceUpdate];
}
For now UINavigationBar changed barPosition from topAttached to top, and so on.

Try this:
- (IBAction)tapShowPhotosButton:(id)sender
{
__statusBarHidden = !__statusBarHidden;
[[UIApplication sharedApplication] setStatusBarHidden:__statusBarHidden withAnimation:UIStatusBarAnimationSlide];
[self setNeedsStatusBarAppearanceUpdate];
}
The Navigation Bar should automatically move with the status bar

I write to technical support and get next answer:
As stated in the documentation for , -positionForBar is called when the bar needs to know its position in its new window. It will not be called when the status bar hides or unhides. The navigation controller handles resizing the navigation bar in response to a status bar change. Unfortunately, UINavigationController does not provide any API to customize the navigation bar resizing behavior.

Related

tab bar style resets after presenting a modal with navigation controller

I want a transparent black theme throughout my iOS app on both navigation bars, tab bars, and toolbars (I use all 3), and I have this set up through storyboards. I have a subclassed tabbar controller that presents a sign up modal with a navigation controller programmatically as follows:
UserSignUpViewController *userSignUpViewController = [self.storyboard instantiateViewControllerWithIdentifier:#"UserSignUpViewController"];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:userSignUpViewController];
userSignUpViewController.delegate = self;
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:navigationController animated:YES completion:nil];
this is called in my subclass tabbars view did appear, so I can see that my tabbar shows up as translucent black before this animates up modally. when I dismiss this sign up navigation controller, the tabbar reverts to "opaque" meaning solid white. Why is this happening and how do I fix it?
The tab/navigation bar tint colors that I set in my appdelegate persist but the translucent styling of the bars gets reset for some reason. I should add that if I don't display the sign up view controller (user is already signed in), then the tab bar is the correct styling. Thanks!
It could be because you are calling it in viewDidAppear instead of viewDidLoad

UISearchBar in navigation bar from UIBarButton in iOS7

I would like to have my search bar launched from a UIBarButton that I have added to my navigation bar from the storyboard. I have also added the Search Bar and Search Display Controller to the document outline in my view controller from the storyboard.
If I implement the code below in my viewDidLoad method the search bar will automatically appear in my navigation bar self.searchDisplayController.displaysSearchBarInNavigationBar = YES;
However, when I try and implement this in from a button click from my navigation bar nothing happens.
(IBAction)serachBarButton:(id)sender
{
self.searchDisplayController.displaysSearchBarInNavigationBar = YES;
}
The IBAction is properly hooked up to the view controller in the storyboard. Any code examples of how to launch the search bar from my navigation button click would be greatly appreciated.

How to hide the NavigationBar when i use SWRevealViewController embed in UINavigationController?

When i use SWRevealViewController as initial view or not embedded in UINavigationController the result is as i expected:
but when the SWRevealViewController comes from UINavigationController tee result is:
How can i avoid the NavigationBar presented in the Rear view?
Please add the following code to the viewWillAppear: method of the viewcontroller whose navigation bar you need to hide.
[super viewWillAppear:YES];
[self.navigationController.navigationBar setHidden:YES];
[self.navigationController.navigationBar.backItem setHidesBackButton:YES];
Try, this code for rear view controller
- (void)viewWillAppear:(BOOL)animated
{
self.navigationController.navigationBar.hidden = YES;
}
If you really need Navigation Controller on top of SWRevealViewController:
You got to hide navigation bar from navigation controller of your SWRevealViewController.
U can do this in IB (assuming you are using Storyboards):
Select Navigation Controller in your Storyboard
Open Attributes inspector
Find section "Navigation Controller", uncheck "Shows Navigation Bar"
Next, If you want navigation bard in front view controller, then attach it to separate Navigation Controller. You will have two Navigation Controllers, think on which one you want to push - it will have different effect.

UIToolbar goes under status bar in iOS7

I have a UIView and I have a UIToolbar and UIWebView.
I want to show toolbar at top of UIView and after that the rest of page covered with webView.
But toolbar goes under status bar like this
How can I correct it in iOS7.
1) Set the toolbar Y position to 20 (in the interface builder or in the code)
2) Set the toolbar delegate
3) In your toolbar delegate implement:
- (UIBarPosition)positionForBar:(id <UIBarPositioning>)bar
{
return UIBarPositionTopAttached;
}
Set up toolbar delegate to your view controller and implement method:
- (UIBarPosition)positionForBar:(id <UIBarPositioning>)bar {
return UIBarPositionTopAttached;
}
The only correct solution in 2k17 is to attach your toolbar/navigationBar to leading/trailing of your superview, top to topLayoutGuideBottom and to implement positionForBar:. This will produce correct result on all devices.

Hide the tab bar in a tab bar application

I have created a new project from the template:
IPhoneOS>Application>Tab Bar Application.
I get two tabs.
How can I make the second become a full screen hiding the tab bar and even the status bar?
I tried to check the "Wants Full screen" - but it didn't help.
(Much less important... When I do get a full screen I do I get back?)
Please give me a simple code/guidelines or a reference to them, cause I'm a beginner - and Me and the compiler got too many issues to make things worse
Thanks
Asaf
To hide the tab bar you can use hidesBottomBarWhenPushed. For instance:
MyController *myController = [[MyController alloc]init];
myController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:myController animated:YES];
[myController release];
To hide the status bar you can use:
[[UIApplication sharedApplication] setStatusBarHidden:YES];
To hide the nav bar you can use:
self.navigationController.navigationBarHidden = YES;
You can just use:
//Navigation bar:
self.navigationController.navigationBarHidden = YES;
//Statusbar:
[[UIApplication sharedApplication] setStatusBarHidden:YES];
//Tabbar:
self.tabBarController.tabBar.hidden = YES;
Have you checked Modal View Controllers out?
http://developer.apple.com/iphone/library/featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html
Try the presentModalViewController:animated: method on your navigationController (instead of pushing a view controller)
[self.navigationController presentModalViewController:foo animated:YES];
Another way to accomplish this is by making the UITabBarController the rootViewController of a UINavigationController. Then when you pushViewControllerAnimated: the tab bar will slide away with the root view controller.