[英]Tableview rows resizing on selection
I have setup a tableview to use self-sizing cells (in fact I didn't have to do anything more than use auto layout - it seems that UITableViewAutomaticDimension
is the default rowHeight). 我已经设置了一个tableview来使用自动调整大小的单元格(实际上,除了使用自动布局外,我不需要做其他任何事情-似乎
UITableViewAutomaticDimension
是默认的rowHeight)。
The cells are sized correctly: 像元大小正确:
However, when I push another controller on to the stack, the cells immediately resize just before the transition animation: 但是,当我将另一个控制器推入堆栈时,单元格会立即在过渡动画之前调整大小:
They remain at the incorrect size when I pop back to the table view controller. 当我弹出表视图控制器时,它们保持不正确的大小。 I can partially resolve this part by reloading on
viewWillAppear
to recalculate the correct heights, but then I lose some other animations and selection state. 我可以通过在
viewWillAppear
上重新加载以重新计算正确的高度来部分解决此部分,但是随后我失去了一些其他动画和选择状态。
Is this an iOS bug? 这是iOS错误吗? How might I work around it?
我应该如何解决?
Here is a sample project that demonstrates the same. 这是一个演示相同项目的示例项目。
You need to set estimatedRowHeight: 您需要设置估计行高度:
- (void)viewDidLoad
{
[super viewDidLoad];
[self.tableView registerClass:[Cell class] forCellReuseIdentifier:@"Cell"];
self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.estimatedRowHeight = 80;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.