pkluz / PKRevealController

PKRevealController is a delightful view controller container for iOS, enabling you to present multiple controllers on top of one another.
Other
3.85k stars 659 forks source link

Can't change status bar style #139

Open morrisHsieh opened 11 years ago

morrisHsieh commented 11 years ago

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

mickeyckm commented 11 years ago

I got the same issue in iOS7.

pirateandy commented 10 years ago

In the file UIViewController+PKRevealController.m add

-(UIStatusBarStyle)preferredStatusBarStyle{ return UIStatusBarStyleLightContent; }

Also in the plist.info file add the UIViewControllerBasedStatusBarAppearance and set the value to YES

mrhevor commented 10 years ago

Nothing to do also following these steps mr pirateandy

fazerbcn commented 10 years ago

You can't add preferredStatusBarStyle on UIViewController+PKRevealController.m,

You should do it on PKRevealController.m, but I think the best option is another one:

On PKRevealController.m, preferredStatusBarStyle is called before PKRevealController is shown on the window, so it's status is still 0, so it uses the default behaviour (if here it should return frontviewController one then maybe nobody found this as a bug).

You should force updating status bar after doing:

adonoho commented 10 years ago

Gentlefolk,

I''m not sure what the problem is you're seeing. I just put the preferredStatusBarStyle on each of my view controllers and everything just seems to work. No patching of PKReveal needed at all.

Anon, Andrew

fazerbcn commented 10 years ago

Hi, Andrew

I've seen at least on iOS7 that no call to preferredStatusBarStyle is done at each change of the viewControllers unless I call setNeedsStatusBarAppearanceUpdate.

And I'm pretty sure you're subclassing the contanier class (UINavigation or UITabbar) to pass the call to your real viewcontroller in the case you have different UIStatusBar for the diferent viewControllers (no need if it's the same for all).

I agree with you that no patching to PKRevealController is necessary (I've seen people telling to do so), just telling that maybe it would be better to select frontviewcontroller instead of nil on the preferredStatusBarStyle of PKRevealController.m, because the first and only time this method is called automatically (before it's put on rootViewController, I've seen no other call till I call setNeedsStatusBarAppearanceUpdate) the PKReveal state is 0, and the function responds UIStatusBarStyleDefault, that correct me if I'm wrong, it doesn't mean the default of your application configured in plist or apperance or so on, it's just black.

I'm pasting the code taken from PKRevealController.m here, the failing quietly in the comment really is returning UIStatusBarStyleDefault (black) whatever your configured frontviewcontroller will be at that moment and will be shown few milliseconds after:

- (UIStatusBarStyle)preferredStatusBarStyle
{
    UIViewController *controller = nil;

    switch (self.state)
    {
        case PKRevealControllerShowsLeftViewControllerInPresentationMode:
        case PKRevealControllerShowsLeftViewController:
            controller = self.leftViewController;
            break;
        case PKRevealControllerShowsRightViewControllerInPresentationMode:
        case PKRevealControllerShowsRightViewController:
            controller = self.rightViewController;
            break;
        case PKRevealControllerShowsFrontViewController:
            controller = self.frontViewController;
            break;

        default:
        {
            // Fail quitely.
        }
            break;
    }

    if ([controller respondsToSelector:@selector(preferredStatusBarStyle)])
    {
        return [controller preferredStatusBarStyle];
    }
    return UIStatusBarStyleDefault;
}