标签:
出现这个问题时, 首先应该仔细看错误, 去除多余的存在冲突的约束,
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:0x170097340 V:|-(0)-[UICollectionView:0x127981200] (Names: ‘|‘:UIView:0x1275336e0 )>", "<NSLayoutConstraint:0x170095680 V:[UICollectionView:0x127981200]-(38)-| (Names: ‘|‘:UIView:0x1275336e0 )>", "<NSLayoutConstraint:0x17009d830 V:[_UILayoutGuide:0x12753f2d0]-(0)-[UIView:0x1275336e0]>", "<NSLayoutConstraint:0x1700973e0 V:[UIView:0x1275336e0]-(416)-[_UILayoutGuide:0x12753f090]>", "<_UILayoutSupportConstraint:0x1742bda60 V:[_UILayoutGuide:0x12753f2d0(0)]>", "<_UILayoutSupportConstraint:0x1742b9560 V:|-(0)-[_UILayoutGuide:0x12753f2d0] (Names: ‘|‘:UIView:0x1275ce900 )>", "<_UILayoutSupportConstraint:0x1742bdbe0 V:[_UILayoutGuide:0x12753f090(0)]>", "<_UILayoutSupportConstraint:0x1742bd9a0 _UILayoutGuide:0x12753f090.bottom == UIView:0x1275ce900.bottom>", "<NSLayoutConstraint:0x174284d80 ‘UIView-Encapsulated-Layout-Height‘ V:[UIView:0x1275ce900(416)]>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x170095680 V:[UICollectionView:0x127981200]-(38)-| (Names: ‘|‘:UIView:0x1275336e0 )> 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.
这些都做完了发现还是报错的话, 看一下代码里改变约束的顺序
- (void)updateViewConstraints { [super updateViewConstraints]; //隐藏筛选框 _siftTopCons.constant = -ScreenHeight+64;//顶部先上去 _siftBottomCons.constant = ScreenHeight-64;//底部再上来 }
比如这个地方, 我让这个View整体往上移动一个屏幕高度, 使其隐藏, 那么应该先把顶部的约束设置完, 再设置底部, 同理, 当要显示的时候, 整个View往下移动一个屏幕高度, 就应该先设置底部的约束, 再设置顶部, 总之就是不要让整个View的大小在设置的过程中发生可能的 尺寸变小
_siftBottomCons.constant = 0;//底部先出来 _siftTopCons.constant = 0;//顶部再向下 [UIView animateWithDuration:0.27 animations:^{ [self.view layoutIfNeeded]; }];
iOS使用代码调整约束做动画效果时出现Unable to simultaneously satisfy constraints.
标签:
原文地址:http://www.cnblogs.com/mcluyu/p/4792460.html