Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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