Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS custom view: Unable to simultaneously satisfy constraints error

I am following Ray Wenderlich's tutorial on implementing a rateView: http://www.raywenderlich.com/1768/how-to-make-a-custom-uiview-a-5-star-rating-view

After implementing a rateView into my app, I got this 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)

( "NSAutoresizingMaskLayoutConstraint:0x870c2b0 h=--& v=--& V:[UIView:0x93a1d60(416)]", "NSLayoutConstraint:0x87363c0 V:|-(203)-[RateView:0x8729040] (Names: '|':UIView:0x93a1d60 )", "NSLayoutConstraint:0x8736440 V:[RateView:0x8729040]-(228)-| (Names: '|':UIView:0x93a1d60 )" )

Will attempt to recover by breaking constraint NSLayoutConstraint:0x8736440 V:[RateView:0x8729040]-(228)-| (Names: '|':UIView:0x93a1d60 )

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.

I downloaded the sample app that Ray provides, and it works perfectly for me, no errors. After searching through code, I don't see any differences, and my connections in Interface Builder are the same as his. The one significant difference was in the size inspector for our individual rate views. His looks like this:

enter image description here

while mine looks like this:

enter image description here

Considering that the error has to do with constraints this is probably the issue. However, I have no clue how to change my rateview to be autoresizing and such like Ray's. Help?

like image 668
USS1994 Avatar asked Feb 17 '23 03:02

USS1994


2 Answers

Uncheck "Use Autolayout" and try....

enter image description here

like image 137
Bhavin_m Avatar answered Apr 06 '23 01:04

Bhavin_m


New Xcode 5 has new feature that awares us from different constaint values. I really appreciate this feature, it reduces errors and differences between that in storyboard and that in simulator and/or device.

Try to follow yellow triangle. It is is located in the left sidebar, when storyboard viewer opened. It brings three solutions how to fix the problem and it goes well and automatically.

So just update Frame, Constraints or reset to suggested constraints.

SOLUTION:

(if you don't see a left sidebar, in new xcode 5 it might be hidden, just click on the play icon):

shows up the left storyboard side bar

Follow the yellow arrow first:

Follow the yellow arrow first

Then follow the yellow triange and after clicking on it you'll get the dialog:

Then follow the yellow triange and after clicking on it you'll get the dialog

like image 28
pedrouan Avatar answered Apr 06 '23 00:04

pedrouan