gpt4 book ai didi

ios - Xcode - 居中分段控制导致错误(Swift)

转载 作者:行者123 更新时间:2023-11-28 13:00:36 26 4
gpt4 key购买 nike

我正试图在我的 Storyboard 中将分段控件居中。我通过向容器边距添加约束前导和尾随空间来实现这一点。

在我这样做之前,它在模拟器中看起来像这样: enter image description here

这是添加约束后在我的 Storyboard中的样子: enter image description here

添加这些约束后,在模拟器中看起来像这样:

enter image description here

我在控制台中收到此错误:

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. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property

最佳答案

将它Center Horizo​​ntally 给父 View 。

出现此问题是因为 Storyboard 中的场景是 600px 宽度,而您从两侧给它硬编码的边距,这就是它在小屏幕上被粉碎的原因。

关于ios - Xcode - 居中分段控制导致错误(Swift),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33998947/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com