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


Sean Lee
Sean Lee
5,196 Points

BlogReader exercise, StoryBoard/TableView issue

Can someone tell me why my tableview is aligning everything to the top into the battery? When i run the app in my iPhone, the top gets cut off.

I followed the BlogReader exercise exactly but i'm still encountering this issue.



2 Answers

Stone Preston
Stone Preston
42,016 Points

thats because the status bar is transparent in iOS 7. That didnt occur in the older versions of iOS when the video was made. To remedy this you can add a table header to your tableView by placing the following code in your viewDidLoad method:

 UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 20)];
 self.tableView.tableHeaderView = headerView;

you can play around with the height of the header (its 20 currently) to get the positioning you want

if you dont like the tableHeader hack you could try adding this in viewDidLoad instead ( I havent tried it so I dont know if this works well or not)

self.tableView.contentInset = UIEdgeInsetsMake(20.0f, 0.0f, 0.0f, 0.0f);
Sean Lee
Sean Lee
5,196 Points

Both hacks work! thanks for the input, really appreciate it.