Search code examples
storyboardautolayoutios7xcode5

Ambiguous Layout - "Height is ambiguous for 'Image View'"


iOS7 has really been jerking me around.

This is a project imported from iOS6 that ran smoothly on all devices I tested on. Somehow the image view pictured gets set to something like 312x400 at runtime, ignoring the specification for height that I set in the storyboard.

I'm aware I'm missing some detail about autolayout but what gives? Why does the height I provided not matter at all, and why is this any different from Xcode4.x/ios6?

Snapshot from Xcode5


Solution

  • The layout for the image view height property is ambiguous. When you use autolayout, it doesn't use the height of the image view in Interface Builder. Instead it uses the constraints set on the image view.

    Create a height constraint on the image view and set it to what you want the height to be (in the case of a fixed height). If you want the height to scale, create constraints for the top and bottom of the image view to the image view's super view. For the screenshot you provided, you may want to set a constraint from the top of the image view to the top layout guide.