user
user

Reputation: 3456

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

Upvotes: 18

Views: 28698

Answers (3)

smart_cai
smart_cai

Reputation: 396

enter image description here

set intrinsic size as Placeholder.

Upvotes: 21

Andrew
Andrew

Reputation: 7720

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.

Upvotes: 20

uchuugaka
uchuugaka

Reputation: 12782

If you are using auto layout, and you are, you need to set constraints that can satisfy vertical and horizontal layout.

In this case it looks like you might want to add height and width constraints to your image view.

Upvotes: 0

Related Questions