Can't change status bar style after applying pkrevealcontroller - statusbar

After apply view controller on pkrevealcontroller, the setting of status bar style just doesn't work.
Setup status bar style to black translucent in project setting => Not working.
Setup status bar style to black translucent in viewWillAppear method => Not working
Without pkrevealcontroller, anything is fine.
Is there anyway to resolve this?
My pkrevealController setup:
MenuViewController *menuVC = [[MenuViewController alloc] initWithStyle:UITableViewStylePlain];
PKRevealController *revealController = [PKRevealController revealControllerWithFrontViewController:self.tabBarController leftViewController:menuVC options:nil];
Set status bar style in viewWillAppear method:
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:YES];
Thanks very much!

Related

Hide statusbar with UINavigationBar barPositionTopAttached

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.

Change status bar back to default after changing it to `Light`, per view Controller scenario

I want to be able to change the status bar color on a per view controller basis. My ViewController flow is A->B->C. The launch status bar color is black (in A), and I change it to white in view Controller B. I use the following in Bs viewDidLoad:
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
[self setNeedsStatusBarAppearanceUpdate];
Which works perfectly. However when I go back to ViewController A, it is white also. I tried using the following code to change it back but it doesnt work:
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
[self setNeedsStatusBarAppearanceUpdate];
I also tried:
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackTranslucent;
But its deprecated and doesnt work.
I have seen the other questions on SO about this, but they tell you how to change it but not change back to default.
Thanks in advance
Setting the navigation bar back to default in viewWillAppear did the trick.

Hide FBFriendPickerViewController navbar when pushing onto UINavigationController

Presenting an instance of FBFriendPickerViewController using presentViewController:animated:completion: is pretty straightforward and the class seems like it is meant for that use case. However, I want to push an instance of FBFriendPickerViewController onto an instance of UINavigationController using pushViewController:animated:.
Consider the following code as an example:
self.fbFriendPickerController = [[FBFriendPickerViewController alloc] init];
self.fbFriendPickerController.hidesBottomBarWhenPushed = YES;
// configure stuff
[[self navigationController] pushViewController:self.fbFriendPickerController animated:YES];
However, the problem is that the instance of FBFriendPickerViewController already has a top navigation bar. When pushed onto a UINavigationController, this results in two top navigation bars stacked vertically, as you can see in the screenshot below.
One solution would be to hide the top nav bar of the UINavigationController, but that creates an awkward transition and there is no back button. Any thoughts on the best way to keep the UINavigationController top nav bar but the hide the FBFriendPickerViewController top nav bar?
After looking through the Facebook iOS SDK source code on Github, I figured this out. FBFriendPickerViewController is a subclass of FBViewController. If you set the doneButton and cancelButton properties of any FBViewController to nil, FBViewController will remove the top navigation bar. As a result, the following code works:
self.fbFriendPickerController = [[FBFriendPickerViewController alloc] init];
self.fbFriendPickerController.hidesBottomBarWhenPushed = YES;
self.fbFriendPickerController.doneButton = nil;
self.fbFriendPickerController.cancelButton = nil;
// configure stuff
[[self navigationController] pushViewController:self.fbFriendPickerController animated:YES];

rightBarButtonItem does not appear in Navigation Bar iOS

I'm having problems displaying the rightBarButtonItem of the Navigation Bar - I'm attempting to create it programmatically in the Application Delegate, where my UINavigationController is set up.
Code is as follows:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
RSCListViewController *list = [[RSCListViewController alloc] initWithStyle:UITableViewStylePlain];
self.navController = [[UINavigationController alloc] initWithRootViewController:list];
UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithTitle:#"+"
style:UIBarButtonItemStylePlain
target:list
action:#selector(addPressed:)];
self.navController.navigationItem.rightBarButtonItem = barButton;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
[DatabaseManager openDatabase];
return YES;
}
Running the application, no button item appears on the navigation bar.
I'm not sure whether I have missed something obvious - my attempts to rectify the problem using related Stack Overflow threads haven't yielded any success.
Any help appreciated.
You need to attach your bar button item to your custom view controller, not to the navigation controller. From Updating the Navigation Bar:
In addition, the navigation controller object builds the contents of
the navigation bar dynamically using the navigation items (instances
of the UINavigationItem class) associated with the view controllers on
the navigation stack. To change the contents of the navigation bar,
you must therefore configure the navigation items for your custom view
controllers.
(...)
The navigation controller updates the right side of the navigation bar
as follows:
If the new top-level view controller has a custom right bar button item, that item is displayed. To specify a custom right bar button
item, set the rightBarButtonItem property of the view controller’s
navigation item.
If no custom right bar button item is specified, the navigation bar displays nothing on the right side of the bar.
Therefore, replace:
self.navController.navigationItem.rightBarButtonItem = barButton;
with:
list.navigationItem.rightBarButtonItem = barButton;

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.