iOS   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 获取大小类中的约束大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

所以,我正在玩 Xcode 6 beta中的大小类.我在图像上设置了一些约束,使其根据与iPhone纵向和横向对应的尺寸类别处于不同的位置. 约束在下面的图像中可见.正如您所看到的,当我处于Compact / Compact时,某些约束被“安装”而其他约束则没有,并且在Compact / Regular中,安装了其他约束. 但是,我得到一个错误(在两个屏幕截图中略微可见)基本上声称我的卸载约束干扰
所以,我正在玩 Xcode 6 beta中的大小类.我在图像上设置了一些约束,使其根据与iPhone纵向和横向对应的尺寸类别处于不同的位置.

约束在下面的图像中可见.正如您所看到的,当我处于Compact / Compact时,某些约束被“安装”而其他约束则没有,并且在Compact / Regular中,安装了其他约束.

但是,我得到一个错误(在两个屏幕截图中略微可见)基本上声称我的卸载约束干扰了我安装的约束(如果它们同时运行,则为真)但不应该为每个大小的卸载约束班甚至没有跑?安装的约束都不会导致彼此之间的问题.

显示错误是:

2014-06-30 21:14:26.215 TV Tracker[26417:1434692] SetAppThreadPriority: setpriority Failed with error 45
2014-06-30 21:14:26.372 TV Tracker[26417:1434692] 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:0x10bb11da0 H:|-(24)-[UILabel:0x10bb4db70'TV Tracker uses your Trak...']   (Names: '|':UIControl:0x10bb2db60 )>","<NSLayoutConsTraint:0x10bb11df0 H:[UIImageView:0x10bb44740]-(>=18)-[UILabel:0x10bb4db70'TV Tracker uses your Trak...']>","<NSLayoutConsTraint:0x10bb2f420 H:|-(20)-[UIButton:0x10bb35470'Sign In']   (Names: '|':UIControl:0x10bb2db60 )>","<NSLayoutConsTraint:0x10bb2f470 UIButton:0x10bb35470'Sign In'.leading == UIImageView:0x10bb44740.leading>"
)

Will attempt to recover by breaking consTraint 
<NSLayoutConsTraint:0x10bb11df0 H:[UIImageView:0x10bb44740]-(>=18)-[UILabel:0x10bb4db70'TV Tracker uses your Trak...']>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConsTraints to catch this in the debugger.
The methods in the UIConsTraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be Helpful.
2014-06-30 21:14:26.373 TV Tracker[26417:1434692] 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:0x10bb11e90 H:[UILabel:0x10bb4db70'TV Tracker uses your Trak...']-(23)-|   (Names: '|':UIControl:0x10bb2db60 )>","<NSLayoutConsTraint:0x10bb11ee0 UILabel:0x10bb4db70'TV Tracker uses your Trak...'.Trailing == UIButton:0x10bb44ec0'Register'.Trailing>","<NSLayoutConsTraint:0x10bb2f510 H:[UIButton:0x10bb44ec0'Register']-(20)-|   (Names: '|':UIControl:0x10bb2db60 )>"
)

Will attempt to recover by breaking consTraint 
<NSLayoutConsTraint:0x10bb11ee0 UILabel:0x10bb4db70'TV Tracker uses your Trak...'.Trailing == UIButton:0x10bb44ec0'Register'.Trailing>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConsTraints to catch this in the debugger.
The methods in the UIConsTraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be Helpful.
2014-06-30 21:14:26.388 TV Tracker[26417:1434692] 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) 
(
"<NSAutoresizingMaskLayoutConsTraint:0x10bb49e10 h=-&- v=-&- UIControl:0x10bb2db60.width == UIViewControllerWrapperView:0x10d102000.width>","<NSAutoresizingMaskLayoutConsTraint:0x10bb55d10 h=-&- v=-&- UIViewControllerWrapperView:0x10d102000.width == UINavigationTransitionView:0x10bc6f770.width>","<NSAutoresizingMaskLayoutConsTraint:0x10bb3cda0 h=-&- v=-&- UINavigationTransitionView:0x10bc6f770.width == UILayoutContainerView:0x10bc6e3e0.width>","<NSAutoresizingMaskLayoutConsTraint:0x10bb29960 h=-&- v=-&- UILayoutContainerView:0x10bc6e3e0.width == UITransitionView:0x10bc73670.width>","<NSAutoresizingMaskLayoutConsTraint:0x10bb559e0 h=-&- v=-&- UITransitionView:0x10bc73670.width == UIWindow:0x10d068e70.width>","<NSAutoresizingMaskLayoutConsTraint:0x10bb56880 h=--- v=--- H:[UIWindow:0x10d068e70(320)]>","<NSLayoutConsTraint:0x10bb2f470 UIButton:0x10bb35470'Sign In'.leading == UIImageView:0x10bb44740.leading>","<NSLayoutConsTraint:0x10bb44570 UIControl:0x10bb2db60.centerX == UIImageView:0x10bb44740.centerX>","<NSLayoutConsTraint:0x10bb3c840 H:[UIImageView:0x10bb44740(92)]>"
)

Will attempt to recover by breaking consTraint 
<NSLayoutConsTraint:0x10bb3c840 H:[UIImageView:0x10bb44740(92)]>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConsTraints to catch this in the debugger.
The methods in the UIConsTraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be Helpful.
2014-06-30 21:14:26.389 TV Tracker[26417:1434692] 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:0x10bd1c8a0 V:[_UILayoutGuide:0x10bb4ACB0(64)]>","<_UILayoutSupportConsTraint:0x10bd1fbf0 V:|-(0)-[_UILayoutGuide:0x10bb4ACB0]   (Names: '|':UIControl:0x10bb2db60 )>","<NSAutoresizingMaskLayoutConsTraint:0x10bb56d40 h=-&- v=-&- UIControl:0x10bb2db60.height == UIViewControllerWrapperView:0x10d102000.height>","<NSAutoresizingMaskLayoutConsTraint:0x10bb56c60 h=-&- v=-&- UIViewControllerWrapperView:0x10d102000.height == UINavigationTransitionView:0x10bc6f770.height>","<NSAutoresizingMaskLayoutConsTraint:0x10bb3cbb0 h=-&- v=-&- UINavigationTransitionView:0x10bc6f770.height == UILayoutContainerView:0x10bc6e3e0.height>","<NSAutoresizingMaskLayoutConsTraint:0x10bb4a920 h=-&- v=-&- UILayoutContainerView:0x10bc6e3e0.height == UITransitionView:0x10bc73670.height>","<NSAutoresizingMaskLayoutConsTraint:0x10bb0e3a0 h=-&- v=-&- UITransitionView:0x10bc73670.height == UIWindow:0x10d068e70.height>","<NSAutoresizingMaskLayoutConsTraint:0x10bb44d20 h=--- v=--- V:[UIWindow:0x10d068e70(568)]>","<NSLayoutConsTraint:0x10bb44520 UIControl:0x10bb2db60.centerY == UIImageView:0x10bb44740.centerY>","<NSLayoutConsTraint:0x10bb445c0 V:[_UILayoutGuide:0x10bb4ACB0]-(24)-[UIImageView:0x10bb44740]>","<NSLayoutConsTraint:0x10bb49b60 V:[UIImageView:0x10bb44740(100)]>"
)

Will attempt to recover by breaking consTraint 
<NSLayoutConsTraint:0x10bb49b60 V:[UIImageView:0x10bb44740(100)]>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConsTraints to catch this in the debugger.
The methods in the UIConsTraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be Helpful.
2014-06-30 21:14:26.396 TV Tracker[26417:1434692] 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:0x10bd13470 V:[_UILayoutGuide:0x10bb4c690(0)]>","<_UILayoutSupportConsTraint:0x10bd13410 _UILayoutGuide:0x10bb4c690.bottom == UIControl:0x10bb2db60.bottom>","<NSLayoutConsTraint:0x10bb11e40 UIControl:0x10bb2db60.centerY == UILabel:0x10bb4db70'TV Tracker uses your Trak...'.centerY + 0.25>","<NSLayoutConsTraint:0x10bb2f3d0 V:[UILabel:0x10bb4db70'TV Tracker uses your Trak...']-(91)-[_UILayoutGuide:0x10bb4c690]>","<NSLayoutConsTraint:0x10bb2d790 V:[UILabel:0x10bb4db70'TV Tracker uses your Trak...'(69)]>"
)

Will attempt to recover by breaking consTraint
@H_154_27@make a symbolic breakpoint at UIViewAlertForUnsatisfiableConsTraints to catch this in the debugger. The methods in the UIConsTraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be Helpful.

Compact / Compact约束的侧边栏看起来像

Compact / Regular约束的侧边栏看起来像

我的登录控制器的视图层次结构:

解决方法

我第一次尝试这个功能时遇到了同样的问题,直到我意识到“”按钮告诉我的是什么.起初,我更改了大小类并删除了视图并添加了视图,或删除了约束并添加了约束.那是错的!您不能在每个大小的类基础上删除添加视图或约束;它们必须全部存在于每个大小类中 – 其中只有一些被标记为“已安装”,而其他大小类则没有.

这是一些进一步的建议.

>查看屏幕截图的顶部.您正在从Interface Builder获得警告 – 并忽略它们.不要忽视它们!这些警告告诉你,你的约束并没有按你认为的那样做.
>显示画布左侧的视图层次结构列表(它隐藏在屏幕截图中)并继续查看并处理每个大小类组合,直到不再有警告为止.它还会告诉您在大量情况下以及您正在查看的特定大小类情况中存在哪些约束和视图(请参见下面的屏幕截图).
>使用右侧属性检查器中的“”按钮确保您具有每个相关大小类案例的值.您不添加删除约束或类:添加“已安装”按钮并标记其大小类并选中或取消选中它们(再次参见屏幕截图).

最后,使用“预览助手”确保视图看起来与您期望的一样.看下面的可爱动画.

大佬总结

以上是大佬教程为你收集整理的ios – 获取大小类中的约束全部内容,希望文章能够帮你解决ios – 获取大小类中的约束所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。