【发布时间】:2015-09-15 21:27:38
【问题描述】:
我想在情节提要中设置约束,但在情节提要中将其停用 一段时间,直到发生用户交互。是否可以?
【问题讨论】:
标签: ios storyboard nslayoutconstraint
我想在情节提要中设置约束,但在情节提要中将其停用 一段时间,直到发生用户交互。是否可以?
【问题讨论】:
标签: ios storyboard nslayoutconstraint
【讨论】:
'Mutating a priority from required to not on an installed constraint (or vice-versa) is not supported. You passed priority 1 and the existing priority was 1000.'
是的,这是可能的。
为该NSLayoutConstraint 创建一个IBOutlet 并将其连接到您在Storyboard 中提到的约束。
@property (nonatomic, strong) IBOutlet UIView *myView;
@property (nonatomic, strong) IBOutlet NSLayoutConstraint *myConstraint;
myConstraint 是对 myView 的约束
在viewDidLoad上写这个代码:[_myView removeConstraint:_myConstraint];
然后,当发生用户交互时:[_myView addConstraint:_myConstraint];
【讨论】:
active,而是使用add、remove,但要保持一个强指针