首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >iOS Autolayout将标签放在图像的顶部

iOS Autolayout将标签放在图像的顶部
EN

Stack Overflow用户
提问于 2015-09-18 14:28:31
回答 2查看 798关注 0票数 0

我正在尝试实现一个UIPageController,这样我的用户就可以在图片库上左右滑动。UIImageView将占据整个背景,而标签将位于as的顶部堆叠。下面是我在接口构建器中的尝试:

由于下面的注释,UIImageView的大小检查器:

但是我在界面构建器中遇到了很多错误,如下所示:

代码语言:javascript
运行
复制
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)]>"
)

我想标签可能被推到图片下面了?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-09-18 18:40:09

首先,一定要像一些研究员提到的那样,在文档大纲中的标签之前有imageView。然后,将imageView调整为主视图的所有边框,并尝试以下约束:

  • 底部空间到: Superview
  • 对齐尾随: Superview
  • 对齐指向: Superview
  • 对齐顶部:超级视图

这些贴在标签上:

  • 从底部到底部的布局:期望的距离
  • 对齐指向Superview:期望的距离
  • 宽度:理想的WITDH
  • 高度:理想高度

希望它能成功。

票数 1
EN

Stack Overflow用户

发布于 2015-09-18 14:53:48

你对标签上的顶部和底部都有限制。如果删除顶部约束,则警告将消失。结果将是正确的。您可以添加宽度和高度约束来标记顶部约束。我希望能帮你。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32654515

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档