gpt4 book ai didi

iOS Autolayout 让标签位于图像之上

转载 作者:行者123 更新时间:2023-11-29 01:38:50 24 4
gpt4 key购买 nike

我正在尝试实现一个 UIPageController,以便我的用户可以在画廊上左右滑动。 UIImageView 将占据整个背景,而标签将像堆叠一样位于顶部。这是我在界面构建器中的尝试:

1

UIImageView 的大小检查器,因为下面有评论: 1

但是我在界面生成器中遇到了很多这样的错误:

2015-09-18 22:19:33.964 ParksonUI[10525:453297] 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 translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x7aec77f0 V:[_UILayoutGuide:0x7aec7330]-(449)-[UILabel:0x7aec6ca0'Over 200 Tips and Tricks']>",
"<NSLayoutConstraint:0x7aec78b0 V:[UILabel:0x7aec6ca0'Over 200 Tips and Tricks']-(20)-[_UILayoutGuide:0x7aec7440]>",
"<_UILayoutSupportConstraint:0x7aec5ee0 V:[_UILayoutGuide:0x7aec7330(64)]>",
"<_UILayoutSupportConstraint:0x7aec6690 V:|-(0)-[_UILayoutGuide:0x7aec7330] (Names: '|':UIView:0x7aec7270 )>",
"<_UILayoutSupportConstraint:0x7aec6540 V:[_UILayoutGuide:0x7aec7440(0)]>",
"<_UILayoutSupportConstraint:0x7aec7220 _UILayoutGuide:0x7aec7440.bottom == UIView:0x7aec7270.bottom>",
"<NSLayoutConstraint:0x7afea660 'UIView-Encapsulated-Layout-Height' V:[UIView:0x7aec7270(519)]>"
)

我认为标签可能被推到了图像下方?

最佳答案

首先,一定要像一些大佬说的那样,在document outline的label前面加上imageView。之后,将 imageView 调整到主视图的所有边框并尝试以下约束:

  • 底部空间到:Superview
  • 将尾部对齐到:Superview
  • 将前导对齐到:Superview
  • 将顶部对齐到:Superview

还有这些标签:

  • 底部空间到底部布局:所需距离
  • 将引导线与 Superview 对齐:所需距离
  • 宽度:所需宽度
  • 高度:理想高度

希望它有用。

关于iOS Autolayout 让标签位于图像之上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32654515/

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