我昨天刚开始学习自动布局,我很难理解这些约束的东西。我以为我正在做正确的自动布局,因为我的故事板没有显示自动布局和约束的问题。我在所有设备中都获得了所有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由于某种原因都被拉伸。
答案 0 :(得分:0)
在UIImageViews
中配置Stack View
,它将图像嵌入在一起,将它们按您想要的方式分隔,然后添加所需的自动布局约束。这是iOS 9的一个新功能。
在Google或您使用的搜索引擎或YouTube上,输入&#34;如何使用堆栈视图&#34;,我相信您的所需教程会弹出。