views:

123

answers:

2

I have a UITableViewCell that I create in tableView:cellForRowAtIndexPath:. In that method I call:

UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil] autorelease];
NSLog(@"Cell height: %f", cell.contentView.frame.size.height);

This gives me a return value of 44.000000.

Then in my tableView:didSelectRowAtIndexPath: method, I call:

UITableViewCell *cell = [tableView cellForRowAtIndexPath: indexPath];
NSLog(@"Cell height: %f", cell.contentView.frame.size.height);

And this gives me a return value of 43.000000. Aren't they the same cell? What gives?

A: 

This is probably due to the separator. Have you looked into that?

Chris Cooper
+1  A: 

I would chock this one up to Apple's behind-the-scenes highlighting magic.

Cory Kilger
Any idea how to get it to display right? Besides just adding 1 to the second height? Seems a bit hackish to me.
Calvin L
Does it not display right? Can you visually see the cell shrink?
Cory Kilger
No, but I have a UIImageView (a checkbox) in there using CGRectOffset() for placement. I calculate the height of the frame so that I can position it, then change the image when the row is selected. But when the new image comes up it moves itself up 1 pixel. I can fix this just by adding a pixel, but it just seems hackish. Maybe I'm just being too uptight.
Calvin L
It does seem hackish, but sometimes you just have to be hackish I guess. Sorry for the lame answer.
Cory Kilger