Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Position and size are ambiguous for "Image view"

I am trying to set a UIImageView has no fixed size and width in the storyboard. I set the leading space to container to greater than or equal to 20, top space to the container to greater than or equal to 20 and trailing space to container to greater than or equal to 20 and vertical spacing to a UICollectionView, the UICollectionView satisfy the constraints. But the UIImageView don't work, it's telling me it's Position and size are ambiguous. How can I make it work? My Idea is no matter how large the image view, it will always keep 20 space to leading, top, trailing and bottom.

I have set the height and width to be greater than or equal to some value and their priority to 999, it's lower than the leading, top and trailing priority. and I have set the imageview to center horizontally. but i get height and vertical position are ambiguous for “Image view”.

like image 394
yong ho Avatar asked Oct 11 '13 09:10

yong ho


2 Answers

Can you see what happens when you add height and width constraints to the UIImageView, but set their priorities to some low value, e.g. 1? It should help, but now UIImageView won't be centered. You can fix it by enclosing UIImageView in another view (empty UIView) and centering it in it both horizontally and vertically.

like image 83
Arek Holko Avatar answered Nov 08 '22 23:11

Arek Holko


When you get this error:

Position and size are ambiguous for “view”

Probably following constraints are missing/incorrectly set:

  1. Width constraint (size issue)
  2. Height constraint (size issue)
  3. Alignment constraints (position issue)
like image 42
Sumoanand Avatar answered Nov 08 '22 23:11

Sumoanand