I have a custom table view cell that uses auto layout and has a disclosure indicator as an accessory view. The cell size of the cells on the screen are completely wrong when first displayed:
As you can see the cell is taking about a 1.5 screens worth of space:
However if I rotate the device and rotate back it looks fine:
As you can see here, I've done nothing complicated:
I have a very NON-IDEAL workaround which is to do:
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self.tableView reloadData];
}
But that obviously causes a 'flash' when you first see the screen. In a more complicated scenario the flash is far more obvious.
I have another workaround but this causes an auto layout exception:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
BasicCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BasicCell" forIndexPath:indexPath];
cell.basicLabel.text = @"Hello this is just some text that should get the label to go over multiple lines";
[cell.basicLabel layoutIfNeeded];
return cell;
}
Exception:
At least this method doesn't give me UI flashing.
If I remove the accessory view it actually works perfectly fine.
UPDATE: I've added a sample project to github: https://github.com/fwaddle/TableCellAccessoryTest
UPDATE #2: Turns out another work around this bug is to layout the cell in code. I just tried doing the same thing in code and it didn't throw the warning and worked fine. Looks like an IB bug.
Any ideas how to work around this issue? Thanks.
rowHeight
property on your table view toUITableViewAutomaticDimension
. Also that is not an exception, that is a warning do to misconfiguration. An uncaught exception will terminate your application. – LexicographyestimatedRowHeight
, I had this problem and when I increased that value it worked perfectly. – LexicographyestimatedRowheight
didn't have an effect. I've uploaded the sample project to github and updated the above with the link. – Photostat