Autolayout – intrinsic size of UIButton does not include title insets

If I have a UIButton arranged using autolayout, its size adjusts nicely to fit its content. If I set an image as button.image, the instrinsic size again seems to account for this. However, if I tweak the titleEdgeInsets of the button, the layout does not account for this and instead truncates the button title. How … Read more

UICollectionView Self Sizing Cells with Auto Layout

I’m trying to get self sizing UICollectionViewCells working with Auto Layout, but I can’t seem to get the cells to size themselves to the content. I’m having trouble understanding how the cell’s size is updated from the contents of what’s inside the cell’s contentView. Here’s the setup I’ve tried: Custom UICollectionViewCell with a UITextView in … Read more

setNeedsLayout vs. setNeedsUpdateConstraints and layoutIfNeeded vs updateConstraintsIfNeeded

I know that the auto layout chain consists in basically 3 different process. updating constraints layout views (here is where we get calculation of frames) display What’s is not totally clear to me is the inner difference between -setNeedsLayout and -setNeedsUpdateConstraints. From Apple Docs: setNeedsLayout Call this method on your application’s main thread when you … Read more

How to trap on UIViewAlertForUnsatisfiableConstraints?

I’m seeing an error appear in my debugger log: Will attempt to recover by breaking constraint <NSLayoutConstraint:0x191f0920 H:[MPKnockoutButton:0x17a876b0]-(34)-[MPDetailSlider:0x17a8bc50](LTR)> Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful. How do I trap on that call? It does not … Read more