1

It seems that one particular aspect of iOS programming is to diagnose these weird, seemingly trivial yet frustratingly obscure small problems.

So today, I was happily woking on my recent iOS project, and I decided to upgrade my project to the latest version ECSlidingViewController, what harm could it do right? Just update a few deprecated methods that's all.

So I did all of that. Everything works fine, beautiful. However, I noticed that the status bar is behaving strangely! It is not appearing when I display one of my underLeftViewController, and it is in a weird shade when I push segue that particular underLeftViewController into one of its subsequent VC. What?? How could this be happening? Anyway, a picture is worth a thousand words:

So here is it acting nice and normal: enter image description here

Now it disappears!!!: enter image description here

Now it has a weird shade!!!: enter image description here

And here is a picture of the app with the sliding view controller slided out: enter image description here

I must have done something crazy to my status bar somewhere, then I thought.

So I looked into my implementation file for the VC where statusbar is acting crazy. It is in fact a subclass of UINavigationController, and its viewDidLoad is empty except with the [super viewDidLoad] line. So nothing suspicious here.

The run test page is in fact the rootViewController for the navVC, so I looked into it. I put all of my view setup code in its viewDidLoad, and this is what it looks like:

- (void)viewDidLoad
{
    [super viewDidLoad];

    // remove advanced button
    self.navigationItem.rightBarButtonItem = nil;

    self.navigationController.view.layer.shadowOffset = CGSizeMake(1, 0);

    // setupGaugeView
    [self setupGauge];

    // add run test button
    [self setupRunTestButton];

    // setup notification container
    CGRect notificationContainerFrame;
    if ([WRGlobalHelper currentDeviceVersion] >= 7) {
        CGFloat statusBarHeight = [WRGlobalHelper statusBarHeight];
        notificationContainerFrame = CGRectMake(0, [[self.navigationController navigationBar] bounds].size.height+statusBarHeight, self.view.bounds.size.width, 1);
        for (UIView *subview in self.view.subviews) {
            CGRect newFrame = subview.frame;
            newFrame.origin.y += [WRGlobalHelper statusBarHeight];
            subview.frame = newFrame;
        }
    } else {
        notificationContainerFrame = CGRectMake(0, [[self.navigationController navigationBar] bounds].size.height, self.view.bounds.size.width, 1);
    }
    self.notificationContainerView = [[UIView alloc] initWithFrame:notificationContainerFrame];
    self.notificationContainerView.clipsToBounds = NO;
    self.notificationContainerView.layer.backgroundColor = [UIColor clearColor].CGColor;
    [self.view addSubview:self.notificationContainerView];

    // some other unrelated stuff omitted....
}

And the `viewDidLoad's for the VCs where the status bar is acting normal or bizarre but with shade is all quite plain as well, they look like

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    [self.view addGestureRecognizer:self.slidingViewController.panGesture];
}

Mind blown and I give up at this point. I've spent nearly 2 hours on this single issue already, and my brain hurts at the thought of the disappearing status bar. The almighty and omniscient SO, please help me! Thank you very much!

santhu
  • 4,796
  • 1
  • 21
  • 29
Enzo
  • 969
  • 1
  • 8
  • 23

1 Answers1

0

The status bar is not disappering, the text is just changing its color based on its assigned Style.
This answer will help

Community
  • 1
  • 1
Andrea
  • 26,120
  • 10
  • 85
  • 131
  • What about the strange shade? That seems like the bar itself is changing color? I'll try the solution in that answer and let you know. – Enzo Jan 26 '14 at 16:09
  • I guess it's just the effect of the status bar on the background color of the underlying view controller. – Andrea Jan 27 '14 at 10:36