ios - Xcode - 宽度和水平位置不明确

标签 ios xcode swift position

我试图弄清楚自动版式是如何工作的,但我遇到了一个问题,我不明白为什么我会收到 View 的“宽度和水平位置不明确”的警告。正如您在我正在处理的 ViewController 的屏幕截图中所见,该 View 是底部的细蓝线:

viewController

箭头和主页按钮没有任何限制。更大灰度 View 的约束如下:

gray view constraints

“作者”标签的约束条件如下:

Authors label constraints

蓝色瘦 View 的约束如下:

blue thin view constraints

我不明白为什么我会收到此警告,因为较大的灰色 View 未收到警告,但我处理这两个 View 的方式似乎没有任何区别。我确保包括对它们两者的前导和尾随空间的限制,那么为什么细蓝色的水平位置不明确?我可以看出为什么宽度可能不明确,但我不明白为什么对于较大的灰色 View 它不会模糊。 autolayout 不应该自动处理吗?我希望宽度明显随屏幕尺寸缩放。

最佳答案

Its better not to put such view inside the top bar, just below the greybar would be best for it if your are doing it just for partition. But I have resolved for your way Here.

对于蓝色条:

  1. 你给“底部空间:”,它不是必需的,因为它由“高度等于:2”维护
  2. 你给“leading space to”和“Align to x”也没有意义。

解决方法:

就这样做吧->

  1. Give "leading space to: superview(greyview)"and "Trailing space to: superview(greyview)"both value 0
  2. 给“top space to:(authors)”一定的值
  3. 最后“高度等于:2”或如您所愿。

enter image description here

greyView的约束

enter image description here

标签的约束

enter image description here

蓝条的约束

enter image description here

关于ios - Xcode - 宽度和水平位置不明确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31173666/

相关文章:

ios - 从 Swift 中的另一个类访问一些值

ios - Objective-C - 弱对象自动注册到 autoreleasepool 中?

ios - 使用 RazorPay SDK - clang : error: linker command failed with exit code 1 (use -v to see invocation)

swift - 这个特定的闭包语句中 = 符号的作用是什么?

ios - UILabel 运行超过屏幕大小

xcode - 标签未显示在 Xcode 模拟器中

xcode - Xcode beta 7.3 (7D162j) 中的 UIFont 错误?

ios - 为什么 NSLineBreakByWordWrapping 有时不起作用

ios - 在 DrawerMenu Tableview 上显示数据

objective-c - Xcode 的 "Incomplete implementation"警告