【问题标题】:xcode 4.6 autolayout doesn't right align view to scrollviewxcode 4.6 自动布局不会将视图右对齐到滚动视图
【发布时间】:2013-06-13 10:36:36
【问题描述】:

我正在使用 iOS 6 自动布局。 我有使用 Interface Builder 创建的肖像模式。 我在UIView(控制器类视图)中有一个UIScrollView。我设置了两个标签:一个与滚动视图右对齐,另一个与视图右对齐。滚动视图比视图短。当我在横向上模拟和旋转时,滚动视图中的标签没有右对齐,但视图中的标签设置正确。

当您单击滚动视图标签并转到Utilities > Size 检查器时,您将看到标签具有约束:Trailing space to: Superview。您不能更改为 ScrollView。

我也在代码中试过这个:

[NSLayoutConstraint constraintWithItem:fileSize
                    attribute:NSLayoutAttributeRight
                    relatedBy:NSLayoutRelationEqual
                    toItem:motherScrollView
                    attribute:NSLayoutAttributeCenterX
                    multiplier:1.0
                    constant:20];

【问题讨论】:

    标签: iphone xcode scrollview autolayout right-align


    【解决方案1】:

    选择 UIScrollView,然后使用 Xcode 中的编辑器菜单更改其他约束。如果它是 UIView 的子视图,则滚动视图的父视图将是 UIView。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-04
      相关资源
      最近更新 更多