Reputation: 4042
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”.
Upvotes: 5
Views: 34920
Reputation: 1326
In cases where the height/width are not ambiguous at runtime, but ambiguous at storyboard time, e.g., setting an image dynamically, having a container view, etc, I try to add constraints with the placeholder checkmark checked to silence xcode.
Upvotes: 0
Reputation: 31
If you are using Stack Views, make sure the Photo Image View is inside the Stack View! (As in the Apple Tutorial)
Upvotes: 2
Reputation: 8929
When you get this error:
Position and size are ambiguous for “view”
Probably following constraints are missing/incorrectly set:
Upvotes: 2
Reputation: 9006
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.
Upvotes: 9
Reputation: 548
If you want to give margin kind of thing into button through coding than please try these if it'll work
[button_Name setTitleEdgeInsets:UIEdgeInsetsMake(0.0, 12.0, 0.0, 0.0)];
I hope this will work..!!!
Upvotes: 0