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 Build a Blog Reader iPhone App Rebuilding from Scratch Adding a Table View Controller Class

Table view in different iOS emulator, problem

Made all this from scratch, coding after the movie. All works fine, but in different emulator got different things. Here is the screenshot, what i get in iOS 6.0 and 7.0 emulators: http://i60.tinypic.com/2ib1347.jpg Don't know how to make this table view look ion iOS7 like in iOS6

3 Answers

Thomas Nilsen
Thomas Nilsen
14,957 Points

One way of doing this, is calling one of UITableView's delegate

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        return some-height;
    }

or Amit answered this a good while back with this:

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

Thanks Thomas,

adding Amit's provided code helps with iOS7, but it also moves a table in iOS6 bit down. Is there any workaround so it would be ok on iOS6 and 7?

Got a working workaround. In viewDidLoad

you need to insert Amit's provided code between if statement, where you check if your iOS version is 7.0 or greater. So it looks like this:

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0f){
   self.tableView.tableHeaderView = [[UIView alloc] 
      initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 20)];
}

This Helps to not mess with iOS 6