【发布时间】:2012-12-14 23:02:39
【问题描述】:
我正在尝试使用代码自动布局来正确处理我的 UIScrollView 中的旋转,该 UIScrollView 包含在运行时为 UIPageControl 的每个页面生成的许多 UILabel。
我没有找到这么多的例子,所以我问是否有人有关于 UIScrollView 和 NSLayoutConstraints 的自动布局的例子。
已编辑 更清楚一点:我在运行时创建不同的 UILabel 并将它们添加到 UIScrollView。纵向是:
(来源:disclafani.org)
在横向时是错误的:
(来源:disclafani.org)
如何使用自动布局解决?我试过使用:
NSLayoutConstraint *cons1=[NSLayoutConstraint
constraintWithItem:label
attribute:NSLayoutAttributeLeft
relatedBy:NSLayoutRelationEqual
toItem:label2 attribute:NSLayoutAttributeLeft
multiplier:1.0
constant:[UIScreen mainScreen].bounds.size.width*-1
];
但它不起作用,我认为这不是正确的方法
【问题讨论】:
-
你有没有看过我指给你的代码示例?
标签: ios uiscrollview autolayout