Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Status bar overwritten by TableView in iOS blog app

The status bar is written over by TableView in the iOS blog. It looks like a printing error in the simulator. I tried it on an iPhone 6+ with iOS 8.0.2 and see the same problem.

What is the proper way to handle the status bar in iOS 8 ?

Thanks in advance...

3 Answers

Stone Preston
Stone Preston
42,016 Points

since the status bar is transparent in iOS7+ views slide up underneath it. you can add an empty tableHeaderView the same height as the status bar to push the tableView down underneath the status bar like so:

//tableViewController

-(void)viewDidLoad
{
     [super viewDidLoad];
     UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 20)];

     self.tableView.tableHeaderView = headerView;

     // ...
}

another option is to embed your view controller in a navigation controller by selecting your tableViewController and then selecting editor -> embed in -> navigation controller from the xcode menu. then select the new navigation controller and uncheck shows navigation bar in the attributes inspector.

Thanks for your response but the status bar is now white. It has pushed the table down but the status bar rectangle is blank.

Stone Preston
Stone Preston
42,016 Points

can you post a screen shot of what you are seeing without the above code, and what you see with it

Initially when I ran it, it didn't work... But tried it on the iPhone 6+ and then back on the simulator and it does display the status bar... thanks

alt text