草庐IT

removeConstraints

全部标签

ios - AutoLayout:removeFromSuperview/removeConstraints 抛出异常并严重崩溃

我们有选择地使用自动布局约束,主要是定位与可编辑字段元素(通常是UITextView、UITextField)相关的标签。然而,由于为这些字段实现了自动布局,每当我们卸载View、取消分配等时,我们都会看到一个令人讨厌的异常和崩溃。异常是在它试图在卸载View之前从View中删除约束时发生的。我们的View/Controller层次结构是这样的:UITableViewController(plainstyle,butwithcellappearancetomimicgroupedstyle)-->UITableViewCell---->UIViewController(containe

ios - AutoLayout:removeFromSuperview/removeConstraints 抛出异常并严重崩溃

我们有选择地使用自动布局约束,主要是定位与可编辑字段元素(通常是UITextView、UITextField)相关的标签。然而,由于为这些字段实现了自动布局,每当我们卸载View、取消分配等时,我们都会看到一个令人讨厌的异常和崩溃。异常是在它试图在卸载View之前从View中删除约束时发生的。我们的View/Controller层次结构是这样的:UITableViewController(plainstyle,butwithcellappearancetomimicgroupedstyle)-->UITableViewCell---->UIViewController(containe

ios - removeConstraint() 不删除约束

我有一个奇怪的问题。我想在某些条件下更改约束,但removeConstraint不起作用。约束不会被删除。代码如下:backButton.translatesAutoresizingMaskIntoConstraints=falseview.removeConstraint(constLabelTop)letconstNew=NSLayoutConstraint(item:label,attribute:.CenterY,relatedBy:.Equal,toItem:backButton,attribute:.CenterY,multiplier:1,constant:0)view.