【问题标题】:Xcode Auto Layout issue with constraints带有约束的 Xcode 自动布局问题
【发布时间】:2016-01-04 22:41:24
【问题描述】:

我昨天刚开始学习自动布局,我很难理解这些约束。我认为我正在正确地进行自动布局,因为我的故事板显示自动布局和约束没有问题。我在所有设备中都得到了我想要的所有 UIImageViews。但是,当我构建时,在调试区域运行一个模拟器,我得到...

     Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. 
Try this: 
    (1) look at each constraint and try to figure out which you don't expect; 
    (2) find the code that added the unwanted constraint or constraints and fix it. 
(
"<NSLayoutConstraint:0x7fabb1d689f0 H:[UIImageView:0x7fabb1d68820(70)]>",
"<NSLayoutConstraint:0x7fabb1e983c0 UIImageView:0x7fabb1d68820.centerX == UIView:0x7fabb1d654c0.centerX - 265>",
"<NSLayoutConstraint:0x7fabb1e98460 UIImageView:0x7fabb1d68820.leading == UIView:0x7fabb1d654c0.leadingMargin    - 20>",
"<NSLayoutConstraint:0x7fabb1e993c0 'UIView-Encapsulated-Layout- Width' H:[UIView:0x7fabb1d654c0(1024)]>"
 )

我在调试区域收到上述消息。此外,当模拟器最终加载时,UIImageViews 都因某种原因而被拉伸。

【问题讨论】:

    标签: ios xcode uiimageview autolayout size-classes


    【解决方案1】:

    Stack View 中配置UIImageViews,它将图像嵌入在一起,按照您的意愿将它们隔开,然后添加所需的自动布局约束。这是 iOS 9 的一项新功能。

    在 Google、您使用的搜索引擎或 YouTube 上,输入“如何使用 Stack Views”,我相信您需要的教程会弹出。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-04-06
      • 2018-07-06
      • 2016-02-04
      • 1970-01-01
      • 1970-01-01
      • 2016-04-07
      • 1970-01-01
      相关资源
      最近更新 更多