1

I am having trouble with my constraints. Any ideas would be appreciated!!

I have tried making a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints using the debugger to catch it, but I didn't know how to solve the problem.

Here is the code:

func makeFullScreen(){
        sceneView.translatesAutoresizingMaskIntoConstraints = false
        NSLayoutConstraint.activate([
            sceneView.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 0),
            sceneView.rightAnchor.constraint(equalTo: self.view.rightAnchor, constant: 0),
            sceneView.leftAnchor.constraint(equalTo: self.view.leftAnchor, constant: 0),
            sceneView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor, constant: 0),
        ])
    }

Here is the 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. 
(
    "<NSLayoutConstraint:0x28234ff70 ARSCNView:0x11a450d60.bottom == UILayoutGuide:0x283932f40'UIViewSafeAreaLayoutGuide'.bottom   (active)>",
    "<NSLayoutConstraint:0x28234fd90 ARSCNView:0x11a450d60.top == UILayoutGuide:0x283932f40'UIViewSafeAreaLayoutGuide'.top   (active)>",
    "<NSLayoutConstraint:0x28234f7f0 ARSCNView:0x11a450d60.centerY == UIView:0x117daeeb0.centerY   (active)>",
    "<NSLayoutConstraint:0x28234fe80 'UIViewSafeAreaLayoutGuide-bottom' V:[UILayoutGuide:0x283932f40'UIViewSafeAreaLayoutGuide']-(34)-|   (active, names: '|':UIView:0x117daeeb0 )>",
    "<NSLayoutConstraint:0x28234fe30 'UIViewSafeAreaLayoutGuide-top' V:|-(44)-[UILayoutGuide:0x283932f40'UIViewSafeAreaLayoutGuide']   (active, names: '|':UIView:0x117daeeb0 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x28234f7f0 ARSCNView:0x11a450d60.centerY == UIView:0x117daeeb0.centerY   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2020-06-23 20:15:25.809104+0100 App[3611:633364] [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. 
(
    "<NSLayoutConstraint:0x28234ff70 ARSCNView:0x11a450d60.bottom == UILayoutGuide:0x283932f40'UIViewSafeAreaLayoutGuide'.bottom   (active)>",
    "<NSLayoutConstraint:0x28234fd90 ARSCNView:0x11a450d60.top == UILayoutGuide:0x283932f40'UIViewSafeAreaLayoutGuide'.top   (active)>",
    "<NSLayoutConstraint:0x28234f610 ARSCNView:0x11a450d60.height == UIView:0x117daeeb0.height   (active)>",
    "<NSLayoutConstraint:0x28234fe80 'UIViewSafeAreaLayoutGuide-bottom' V:[UILayoutGuide:0x283932f40'UIViewSafeAreaLayoutGuide']-(34)-|   (active, names: '|':UIView:0x117daeeb0 )>",
    "<NSLayoutConstraint:0x28234fe30 'UIViewSafeAreaLayoutGuide-top' V:|-(44)-[UILayoutGuide:0x283932f40'UIViewSafeAreaLayoutGuide']   (active, names: '|':UIView:0x117daeeb0 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x28234ff70 ARSCNView:0x11a450d60.bottom == UILayoutGuide:0x283932f40'UIViewSafeAreaLayoutGuide'.bottom   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
mick1996
  • 516
  • 9
  • 31

1 Answers1

2

The error message is clear. You cannot set top-and-bottom and centerY-and-height. That's an overdetermination. Pick top-and-bottom or else centerY-and-height.

It's interesting to ask yourself where the centerY/height constraints are coming from, because they are not in the code you've shown, so I don't know the answer to that one. There must be some more code somewhere else. Perhaps those are constraints you set up earlier? If so, you will have to start by removing them now.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • thank you very much for your response! I had a quick look there and I do not set the centerY constraints on this particular view controller. Is there another possible problem? – mick1996 Jun 23 '20 at 20:02
  • 1
    No, there isn't. Whether you did it in code or in the storyboard, you already have centerY and height constraints on this view, before the code you've shown runs. – matt Jun 23 '20 at 20:11
  • In the end, I set constraints on the storyboard and again using NSLayoutConstraints – mick1996 Jul 10 '20 at 22:14
  • Yes, that's what I said. :) I'm glad you see what I was talking about. – matt Jul 10 '20 at 22:19