I posypaneDlaczego self.frame i self.contentView.frame często różnią się dla UITableViewCell?
NSAssert(abs(self.frame.size.height-self.contentView.frame.size.height)<=1,@"Should be the same");
w różnych miejscach podczas tworzenia UITableViewCell do powrotu.
Wynik często jest różny. Czasami o 1 piksel, czasami o 2.
Zastanawiam się, jaki jest problem? Czy jest coś w cellForRowAtIndexPath, co czyni je innymi?
Zaczynają to samo. Nie ma edycji itp
Spójrz na ten prosty snipet
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.
Jednakże nie po ja dequeue komórka czasami ostatni.
Jest to wynik
(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>>
Przy okazji tableView jest w trybie zgrupowane. Myślę, że ma to coś wspólnego z tym.
Mark, czy mógłbyś wyjaśnić, dlaczego szerokość komórki i zawartość komórki nie są takie same? –