我有动态大小的标签和表格视图行高。有些东西似乎不起作用。我将标签的宽度记录在cellForRowAtIndexPath:
.
Loading in Portrait --> 595
Rotate to Landscape --> 851
Rotate to Portrait --> 595
看起来不错。但
Loading in Landscape --> 595
Rotate to Portrait --> 595
Rotate to Landscape --> 851
实际上,在横向模式下加载视图时,我的视图标签和单元格未正确呈现。
有任何想法吗?
编辑:
当我旋转时,我只需reloadData
调用didRotateFromInterfaceOrientation:
. 这就像一个魅力。
我不会在任何地方更改标签的宽度,只是更改高度。(当然,宽度对于计算高度很重要,但我并没有改变宽度。)
日志语句在 的末尾,cellForRowAtIndexPath
它总是在 之后 heightForRowAtIndexPath
调用,因此之后没有更多的变化。
编辑 2:
有问题的标签是动态创建的。我现在切换到为每个方向使用不同的框架:
// in cellForRowAtIndexPath
BOLL landscape = UIInterfaceOrientationIsLandscape(
[[UIApplication sharedApplication] statusBarOrientation]);
//...
textFieldFrame = CGRectMake(x, y, landscape ? 851 : 595, h);
使用此帧初始化标签。