I sprinkled
NSAssert(abs(self.frame.size.height-self.contentView.frame.size.height)<=1,@"Should be the same");
in different places when creating a returned UITableViewCell.
The result is often different. Sometimes 1 pixel, sometimes 2.
I wonder what the problem is? Is there something else in cellForRowAtIndexPath?
They start the same thing. No editing, etc.
Look at this simple sniper.
BGDetailTableViewCell * cell= (BGDetailTableViewCell*)[tableView dequeueReusableCellWithIdentifier:[BGDetailTableViewCell reuseIdentifier]]; if (cell==nil) { cell = [[BGDetailTableViewCell alloc]init]; } else { NSAssert(abs(cell.frame.size.height-cell.contentView.frame.size.height)<=1,@"Should be the same"); //Sometimes this fail } NSOrderedSet *Reviews = [self.businessDetailed mutableOrderedSetValueForKey:footer.relationshipKey]; Review * theReview = [Reviews objectAtIndex:row]; cell.theReview = theReview; NSAssert(abs(cell.frame.size.height-cell.contentView.frame.size.height)<=1,@"Should be the same");//This one never fail right before returning cell return cell; `NSAssert(abs(cell.frame.size.height-cell.contentView.frame.size.height)<=1,@"Should be the same")`; never fails right before returning the cell.
However, this fails after I crossed out the cell, sometimes the last one.
This is the result.
(lldb) po cell $0 = 0x0c0f0ae0 <BGDetailTableViewCell: 0xc0f0ae0; baseClass = UITableViewCell; frame = (0 424; 320 91); hidden = YES; autoresize = W; userInteractionEnabled = NO; layer = <CALayer: 0xc01e800>> (lldb) po cell.contentView $1 = 0x0c086080 <UITableViewCellContentView: 0xc086080; frame = (10 1; 300 89); gestureRecognizers = <NSArray: 0xc0c7ee0>; layer = <CALayer: 0xc0ebbf0>>
By the way, tableView is in grouped mode. I think this has something to do with it.
source share