使用自动布局为iOS8今日扩展设置固定高度

 我的 发布于 2022-12-20 16:40

我正在尝试实现一个简单的今天小部件,其中包含一个固定高度的单个标签.

在文档中它说:

如果窗口小部件具有要显示的其他内容,则可以依赖"自动布局"约束来适当调整窗口小部件的高度.

但是我一直得到"无法同时满足约束"的警告.

这是我尝试过的:

    创建一个新的"今日扩展"目标,它创建一个带有"Hello World"标签和视图控制器的故事板.

    将高度约束设置为"Hello World"标签.

在此输入图像描述

当我跑步时,我得到:

2014-09-18 21:13:07.123 TestWidget[23381:871330] 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) 
(
    "",
    "",
    "",
    "<_UILayoutSupportConstraint:0x7f87c3021980 V:[_UILayoutGuide:0x7f87c30222b0(0)]>",
    "<_UILayoutSupportConstraint:0x7f87c30218a0 V:|-(0)-[_UILayoutGuide:0x7f87c30222b0]   (Names: '|':UIView:0x7f87c3112f20 )>",
    "<_UILayoutSupportConstraint:0x7f87c3023360 V:[_UILayoutGuide:0x7f87c3022f00(0)]>",
    "<_UILayoutSupportConstraint:0x7f87c3023300 _UILayoutGuide:0x7f87c3022f00.bottom == UIView:0x7f87c3112f20.bottom>",
    ""
)

Will attempt to recover by breaking constraint 


Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in  may also be helpful.

我究竟做错了什么?使用自动布局创建具有固定高度的窗口小部件的正确方法是什么?

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有