Unable to simultaneously satisfy constraints

后端 未结 6 1317
暖寄归人
暖寄归人 2020-12-28 18:22

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

相关标签:
6条回答
  • 2020-12-28 18:31

    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)
        }
    }
    
    0 讨论(0)
  • 2020-12-28 18:33

    Try this steps, it helps me.

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

    0 讨论(0)
  • 2020-12-28 18:34

    In my case, I was getting this error due to a Navigation Bar. Adding New UIViewController was causing this error.

    I removed the old navigation bar and then re-added it by going to EditorEmbed InNavigation Controller.

    0 讨论(0)
  • 2020-12-28 18:46

    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;
    
    0 讨论(0)
  • 2020-12-28 18:50

    I reset to suggested Constraints and it resolved the issue, see here.

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

    0 讨论(0)
  • 2020-12-28 18:51

    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.

    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:)

    0 讨论(0)
提交回复
热议问题