Height of iOS8 Today Extension using Only Auto Layout Gives Broken Constraints Height of iOS8 Today Extension using Only Auto Layout Gives Broken Constraints ios ios

Height of iOS8 Today Extension using Only Auto Layout Gives Broken Constraints


After some experimenting, and stumbling across "what is NSLayoutConstraint "UIView-Encapsulated-Layout-Height" and how should I go about forcing it to recalculate cleanly" I determined that you can circumvent this problem using either "Height" & "Equal Heights" OR "Height" and Top and Bottom "Vertical Space" (as suggested by Guilherme Sprint), and then decreasing the "Priority" of the height constraint to 999.

Height Constraint with Reduced Priority

This isn't the answer I was hoping for, but it does specify the height of the container via Auto Layout of the subview and avoids any warnings about broken constraints.

My entirely unscientific guess/assumption/conclusion is that iOS is correctly looking at the layout constraints to determine the height of the container view. It then adds a new constraint that is the same height as what it just calculated, but this now over-constrains the height. Reducing the priority on the original developer specified height constraint means the system generated constraint wins out and no warning is generated (would love to hear more about this from someone who actually knows).


You should define 5 constraints in total to make the Today Extension the size that you really want.

4 constraints will define the relation with the superview:

  • Top Space
  • Bottom Space
  • Leading Space
  • Trailing Space

By the way, you should hook this constraints to the layout margins, as Apple recommends for view, and specially Today Extensions.

The 5th constraint will be the Height for the subview. This constraint, together with the top and bottom spaces, will define the exact size of your section inside Today Tab.

Xcode Today Extension Constraints

Just explaining that, the height constraint will set a constant for the subview, and the top and bottom constraints will "glue" the superview to the subview edges.

Today Extension running


The height of the label makes it impossible to satisfy at the same time these constraints:

  • Label minimum height
  • Top Space to Superview
  • Bottom Space to Superview

You can solve it by removing the Bottom Space to Superview constraint, and the autolayout system will assign bottom space the remaining space.