2

I use an UITableViewController into a Navigation Controller that comes up when an UIButton pressed. When the button has been pressed the TableViewController comes up without status bar. If i select a cell of the TableViewController and then getBack the Status Bar appears properly. I don't know the reason that this happens. I want the Status Bar to appear every time. I tried to set Status Bar from StoryBoard but it did't work. I also tried a lot of solutions programmatically from here.

This is the part of Storyboard that shows the TableViewController and the options that have been selected.

Storyboard

This is the wrong result:

wrong

If I select a cell and get back to the TableViewController I have this result:

right

I want to have the result of third pic every time.

P.S. In my .plist file I have View controller-based status bar appearance set to YES.

I have added to my viewDidLoad this Line:

    [self setNeedsStatusBarAppearanceUpdate];

And below of viewDidLoad this method:

-(UIStatusBarStyle)preferredStatusBarStyle{
    return UIStatusBarStyleLightContent;
}

And it shows only the battery life.

Mihir Oza
  • 2,768
  • 3
  • 35
  • 61
hoya21
  • 893
  • 7
  • 24
  • are you check viewDidLoad and ViewWillAppear method ? may be there is anything wrong. – iPatel Mar 21 '14 at 09:00
  • @iPatel thanks for the response. Yes, i have checked these methods but there is not something that handles with status bar. – hoya21 Mar 21 '14 at 09:03

3 Answers3

2

If anyone has the same problem in future, this is the answer.

Step 1: Add this to your .plist file.

View controller-based status bar appearance ---> NO

Step 2: These two lines to your appDelegate into didFinishLaunchingWithOptions method.

[[UIApplication sharedApplication] setStatusBarHidden:NO];

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
Community
  • 1
  • 1
hoya21
  • 893
  • 7
  • 24
0

Here's a post that explains well how to set the status bar ViewController based: iOS 7 and later: set status bar style per view controller

Community
  • 1
  • 1
Tijn
  • 568
  • 4
  • 7
0

If there is nothing code about related to statusBar in viewDidLoad and ViewWillAppear Then fix it by using [[UIApplication sharedApplication] setStatusBarHidden:NO animated:NO]; write this code in ViewWillAppear method.

iPatel
  • 46,010
  • 16
  • 115
  • 137