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

Blog reader app - Table cells touching the header

Hi - I am working on the IOS7 and when I run the table view, the cell starts with on the top. Touching the top of the simulator. Is anyone facing same issue?

6 Answers

Thomas Nilsen
Thomas Nilsen
14,957 Points

Or you could do something like this:

NSInteger cellCount = [self tableView:tableView numberOfRowsInSection:indexPath.section];
return self.view.frame.size.height / (CGFloat)cellCount;

That is what you put inside of the delegate method

Thomas Nilsen
Thomas Nilsen
14,957 Points

You need to implement

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
}

It's one of the tableView's delegates .

Hi Thomas,

Thanks. I am pretty new to IOS dev. What kind of code would go into this

Thanks, Nitin

Thomas Nilsen
Thomas Nilsen
14,957 Points

The function returns a float. So If you were to write "return 60.0f" (Try it out), that would happen to all the cells. What you need to do, is locate the first cell and set the approriate height :)

cool thanks this work. I was wondering that is this a bug or a feature that came with IOS 7 and X5? It was not the case previously