本文介绍了在InterfaceBuilder中启用/禁用NSLayoutConstraints的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

NSLayoutConstraint (在 iOS 8.0 中)有一个 BOOL 名为 active 的属性,可以轻松地即时禁用/启用所述布局约束。

NSLayoutConstraint (in iOS 8.0) has a BOOL property called active which makes it easy to disable/enable said layout constraint on-the-fly.

To为视图控制器创建第二个布局集,然后我可以通过编程方式启用/禁用(通过 IBOutletCollection NSLayoutConstraints 两套),我需要在界面构建器中禁用我已经定义的布局约束。

To create a second layout set for a view controller which I can then programmatically enable/disable (via an IBOutletCollection of NSLayoutConstraints for both sets) , I'll need to disable my already defined layout constraints in interface builder.

让我在这里清楚我不想删除它们,只是禁用它们以便我可以设计第二组而不会让接口构建器一直抱怨不匹配的约束。
此外,切换大小类不是一个选项,因为布局集适用于同一个大小的类。

Let me clear here I do NOT want to delete them, just disable them so that i can design a second set without interface builder complaining all the time about mismatching constraints.Furthermore switching size classes is not an option, since the layout sets are meant for one and the same size class.

有没有选项可以这样做?

Is there an option to do so?

提前致谢

Malte

进一步信息: SDK版本:8.1 部署目标8.0

推荐答案

在故事板中选择要禁用的约束,并选择 + + 以显示属性检查员,然后取消选择已安装。

Select the constraint you want to disable in storyboard, and ++ to show Attributes Inspector, then unselect Installed.

这篇关于在InterfaceBuilder中启用/禁用NSLayoutConstraints的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 19:28