我正在开发一个目标为 iOS7 的应用程序,当我将该应用程序部署到 iPhone 4 时出现以下错误。
[NSLayoutConstraint setActive:]: unrecognized selector sent to instance
我调查了一下,发现 setActive
是在 iOS8 中引入的。问题是,在 iOS7 左右,setActive
的替代方案是什么?我需要以编程方式操纵约束,但似乎无法在任何地方找到答案。
最佳答案
另一种方法是从 View 中添加/删除约束:
[myView addConstraint:constraint];
[myView removeConstraint:constraint];
这从 iOS 6.0 开始可用。 https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/index.html#//apple_ref/occ/instm/UIView/addConstraint:
关于ios - 停用 NSLayoutConstraint iOS 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31167248/