0
我只是尝试创建我自己的布局。我使用UITableView
作为我的UIViewController
。我有一些来自服务器的JSON响应。这就像详细的出版物。另外我计算我的UITableViewCell
高度,因为我的出版物包含图像和文字的混合。我编写了自己的布局,并在设备旋转时重新计算。如何正确布局
for (UIView * sub in contentSubviews) {
if([sub isKindOfClass:[PaddingLabel class]])
{
PaddingLabel *textPart = (PaddingLabel *)sub;
reusableFrame = textPart.frame;
reusableFrame.origin.y = partHeight;
partHeight += textPart.frame.size.height;
[textPart setFrame:reusableFrame];
} else if([sub isKindOfClass:[UIImageView class]])
{
UIImageView * imagePart = (UIImageView *)sub;
reusableFrame = imagePart.frame;
reusableFrame.origin.y = partHeight;
reusableFrame.origin.x = screenWidth/2 - imageSize.width/2;
reusableFrame.size.width = imageSize.width;
reusableFrame.size.height = imageSize.height;
[imagePart setFrame:reusableFrame];
partHeight += imagePart.frame.size.height;
}
}
但我有一些问题。 当设备更改方向状态UIScrollView
偏移量与以前相同时。我不知道如何改变它。 循环之前:
旋转后:
我想保存在矩形可见元素。 建议请。