Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 797
user Avatar asked Sep 22 '13 03:09

user


2 Answers

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.

like image 176
Andrew Avatar answered Oct 07 '22 02:10

Andrew


enter image description here

set intrinsic size as Placeholder.

like image 22
smart_cai Avatar answered Oct 07 '22 02:10

smart_cai