Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to simultaneously satisfy constraints

Actually integrated camera application using xib, in that I placed uiview on a view, after that I put imageview, again view on imageview for cropping. then run the project I got this error.

2013-07-23 12:45:49.936 Camera_App1[30668:907] 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)

(
    "<NSAutoresizingMaskLayoutConstraint:0x1f5b3d10 h=--& v=--& V:[UIView:0x1f5a2f70(460)]>",
    "<NSLayoutConstraint:0x1f5a3c80 V:[UIView:0x1f5a31b0]-(385)-|   (Names: '|':UIView:0x1f5a3120 )>",
    "<NSLayoutConstraint:0x1f5a3f80 V:|-(0)-[UIView:0x1f5a3120]   (Names: '|':UIView:0x1f5a2f70 )>",
    "<NSLayoutConstraint:0x1f5a3f40 V:[UIView:0x1f5a3120]-(63)-|   (Names: '|':UIView:0x1f5a2f70 )>",
    "<NSLayoutConstraint:0x1f5a3bc0 V:|-(61)-[UIView:0x1f5a31b0]   (Names: '|':UIView:0x1f5a3120 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x1f5a3c80 V:[UIView:0x1f5a31b0]-(385)-|   (Names: '|':UIView:0x1f5a3120 )>

Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2013-07-23 12:45:58.697 Camera_App1[30668:907] media type=public.image
2013-07-23 12:45:58.701 Camera_App1[30668:907] global=public.image
2013-07-23 12:45:58.858 Camera_App1[30668:907] 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:0x1f5a3c80 V:[UIView:0x1f5a31b0]-(385)-|   (Names: '|':UIView:0x1f5a3120 )>",
    "<NSLayoutConstraint:0x1f5a3f80 V:|-(0)-[UIView:0x1f5a3120]   (Names: '|':UIView:0x1f5a2f70 )>",
    "<NSLayoutConstraint:0x1f5a3f40 V:[UIView:0x1f5a3120]-(63)-|   (Names: '|':UIView:0x1f5a2f70 )>",
    "<NSLayoutConstraint:0x1f5a3bc0 V:|-(61)-[UIView:0x1f5a31b0]   (Names: '|':UIView:0x1f5a3120 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x1f53a430 h=--& v=--& V:[UIView:0x1f5a2f70(460)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x1f5a3c80 V:[UIView:0x1f5a31b0]-(385)-|   (Names: '|':UIView:0x1f5a3120 )>

Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
like image 458
Thanush Shre Avatar asked Jul 23 '13 07:07

Thanush Shre


People also ask

How do you solve unable to simultaneously satisfy constraints?

"[LayoutConstraints] 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.

What is AutoLayout?

Auto layout is a system which lets you perform lay out using mathematical relationships. It is based on the incremental cassowary constraint solving toolkit and uses the awesome Cassowary. js library. AutoLayout.


4 Answers

The error is what it says, and gives quite clear instructions for you to begin debugging. There are two constraints that conflict. Each instructs the Auto Layout runtime to do something that contradicts the other.

If you are creating and adding views programmatically, then chances are Auto Resizing attributes have been automatically translated to Auto Layout constraints.

So, the first thing to try is, with your programmatically created views, disable this by setting:

myProgrammaticView.translatesAutoresizingMaskIntoConstraints = NO;
like image 199
Max MacLeod Avatar answered Sep 18 '22 15:09

Max MacLeod


I had the same problem, after hours of searching, it turned out the problem was because in-call or hotspot status bar was toggled, (hotspot is on, in a phone call), to fix the problem, in appdelegate I added:

    func application(application: UIApplication, willChangeStatusBarFrame newStatusBarFrame: CGRect) {
    let windows = UIApplication.sharedApplication().windows

    for window in windows {
        window.removeConstraints(window.constraints)
    }
}
like image 22
Omar Albeik Avatar answered Sep 20 '22 15:09

Omar Albeik


Try this steps, it helps me.

Select your object > Editor > Resolve Auto Layout Issues > Reset to Suggested Constraints

enter image description here

like image 27
code-8 Avatar answered Sep 18 '22 15:09

code-8


I know this thread is very old but this is my experience and Solution.

Select view (UILabel, UIImage etc) Editor > Pin > (Select...) to Superview Editor > Resolve Auto Layout Issues > Add Missing Constraints

This error is to conflict between constraints that you have added. Remove the constraints that are not required. Not to use more than one constraint in the same direction and type.

enter image description here

I would recommend that you use SnapKit. It is an Autolayout framework, very convenient to use

 import SnapKit

 var label = UILabel()

 label.snp_makeConstraints { (make) -> Void in
    make.centerX.equalTo(0)
    make.centerY.equalTo(0)
    make.width.equalTo(30)
    make.height.equalTo(30)
 }

https://github.com/SnapKit/SnapKit Hope this is helpful:)

like image 21
Milap Jhumkhawala Avatar answered Sep 21 '22 15:09

Milap Jhumkhawala