简体   繁体   English

iOS自动版式无法同时满足约束

[英]iOS Auto Layout Unable to simultaneously satisfy constraints

My code snippet is as below 我的代码段如下

    self.sortOptionsViewSmall.hidden = !self.sortOptionsViewSmall.hidden;
    self.sortOptionsView.hidden=YES;
    [UIView animateWithDuration:0.4 animations:^{

        **self.sortViewHeightSmall.constant = (self.sortViewHeightSmall.constant == 0) ? 187 : 0;**
        self.sortViewHeightConstraint.constant = (self.sortViewHeightSmall.constant == 187) ? 187 : 0;
        self.tableViewHeightConstraint.constant = self.sortViewHeightSmall.constant == 0 ? 664 : 477;

        [self.view layoutIfNeeded];
    }];

If I navigate to some other view and navigate back the 如果我导航到其他视图并向后导航,

self.sortViewHeightSmall.constant = (self.sortViewHeightSmall.constant == 0) ? 187 : 0;

gives me below error 给我下面的错误

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:0x181643e0 V:[SortOptionsView:0x18162970(187)]>",
"<NSLayoutConstraint:0x18162ac0 V:[SortOptionsView:0x18162010(0)]>",
"<NSLayoutConstraint:0x18155170 V:[SortOptionsView:0x18162970]-(0)-    
[UITableView:0xea98e00]>",
"<NSLayoutConstraint:0x181551a0 V:[SortOptionsView:0x18162010]-(0)-
[UITableView:0xea98e00]>",
"<NSLayoutConstraint:0x18155260 V:[UIView:0x181544e0]-(0)-
[SortOptionsView:0x18162010]>",
"<NSLayoutConstraint:0x18155290 V:[UIView:0x181544e0]-(0)-
[SortOptionsView:0x18162970]>"
)

Will attempt to recover by breaking constraint 将尝试通过打破约束来恢复

<NSLayoutConstraint:0x181643e0 V:[SortOptionsView:0x18162970(187)]>

Break on objc_exception_throw to catch this in the debugger. 中断objc_exception_throw以在调试器中捕获此错误。 The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful. <UIKit/UIView.h>列出的UIViewUIConstraintBasedLayoutDebugging类别中的方法也可能会有所帮助。 this error.** 此错误。**

I tried to use setTranslatesAutoresizingMaskIntoConstraints:NO but it is not working. 我尝试使用setTranslatesAutoresizingMaskIntoConstraints:NO但是它不起作用。

Any help is appreciated. 任何帮助表示赞赏。

Check your code. 检查您的代码。 In error stack i see two constraits with conflict: 在错误堆栈中,我看到两个冲突的环境:

"<NSLayoutConstraint:0x181643e0 V:[SortOptionsView:0x18162970(187)]>",
"<NSLayoutConstraint:0x18162ac0 V:[SortOptionsView:0x18162010(0)]>",

SortOptionsView can't understand, what will be it height size 187 points or 0? SortOptionsView无法理解,高度大小为187点或0是什么? You can resolve this conflict with 2 ways: 您可以通过以下两种方法解决此冲突:

  1. delete one constrait; 删除一个等式;
  2. set priority for each conflict constraits; 为每个冲突地区设置优先级;

I hope i sent you on the right path. 我希望我以正确的方式送你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 以编程方式应用自动布局约束时无法同时满足约束 - Unable to simultaneously satisfy constraints while applying auto layout constraints programatically AVPlayerViewController-无自动版式-无法同时满足约束。 - AVPlayerViewController - No Auto Layout - Unable to simultaneously satisfy constraints. 自动布局错误无法同时满足 UIScrollView 的约束 - Auto layout error Unable to simultaneously satisfy constraints with UIScrollView 无法同时满足约束 iOS - Unable to simultaneously satisfy constraints iOS iOS:无法同时满足约束 - iOS: Unable to simultaneously satisfy constraints iOS“无法同时满足约束条件” - iOS “Unable to simultaneously satisfy constraints” iOS 8运行正常,由于视图转换影响布局约束,iOS 7无法同时满足约束 - iOS 8 works fine, iOS 7 gets Unable to simultaneously satisfy constraints due to view transform affecting layout constraints iOS:在segue中无法同时满足约束 - iOS: Unable to simultaneously satisfy constraints when in segue iOS,Swift:系统日志中“无法同时满足约束条件” - iOS, Swift: “Unable to simultaneously satisfy constraints” in syslog iOS-AutoLayout&#39;无法同时满足约束&#39; - iOS - AutoLayout 'Unable to simultaneously satisfy constraints'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM