0

我有动态大小的标签和表格视图行高。有些东西似乎不起作用。我将标签的宽度记录在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); 

使用此帧初始化标签。

4

2 回答 2

0

解决方案:再次设置框架

-(void)willDisplayCellAtIndexPath:
于 2012-08-17T16:17:32.283 回答
0

看起来您确实没有检查横向加载时会发生什么。更多代码将为您提供修复:-)

于 2012-08-17T15:26:47.143 回答