Unable to simultaneously satisfy constraints – No constraints in place

Let’s look at these one by one. “<NSAutoresizingMaskLayoutConstraint:0x84543d0 h=–& v=–& V:[UIView:0xa330270(768)]>” This is saying view 0xa330270 (A) must be 768 points high. “<NSLayoutConstraint:0xa338350 V:[UIView:0xa331260]-(-1)-| (Names: ‘|’:UIView:0xa330270 )>” This is saying view 0xa331260 (B)’s bottom edge must be a gap of -1 from the bottom of A, which is it’s superview. “<NSLayoutConstraint:0xa338390 V:|-(841)-[UIView:0xa331260] (Names: ‘|’:UIView:0xa330270 )>” … Read more

setNeedsLayout vs. setNeedsUpdateConstraints and layoutIfNeeded vs updateConstraintsIfNeeded

Your conclusions are right. The basic scheme is: setNeedsUpdateConstraints makes sure a future call to updateConstraintsIfNeeded calls updateConstraints. setNeedsLayout makes sure a future call to layoutIfNeeded calls layoutSubviews. When layoutSubviews is called, it also calls updateConstraintsIfNeeded, so calling it manually is rarely needed in my experience. In fact, I have never called it except when … Read more

UITextView inside UIScrollView with AutoLayout

After a few days of research and getting my hands dirty with UIScrollView + UITextView + Auto Layout, I successfully got a fully working UIScrollView. I want to share my solution just in case someone might stuck on the same situation. Add UIScrollView inside the main view in Storyboard Add UIView inside the UIScrollView Add … Read more

With Auto Layout, how do I make a UIImageView’s size dynamic depending on the image?

The image view’s intrinsic size is already dependent on the size of the image. Your assumptions (and constraints are correct). However, if you’ve set up your image view in interface builder and have not provided it with an image, then the layout system (interface builder) won’t know how big your image view is supposed to … Read more

How to update the constant height constraint of a UIView programmatically?

Select the height constraint from the Interface builder and take an outlet of it. So, when you want to change the height of the view you can use the below code. yourHeightConstraintOutlet.constant = someValue yourView.layoutIfNeeded() Method updateConstraints() is an instance method of UIView. It is helpful when you are setting the constraints programmatically. It updates … Read more