1

I have a simple UITableViewController, tableview setup as static, I have only one UITableViewCell inside it, UITableViewCell has one UIImageView and one label inside it.

enter image description here

Constraints added are as follows

enter image description here

When I run this app , everything looks fine except the image doest stay square that is UIIMageView looses its width and height constraints and shows the entire image. Scale type used is Aspect Fill. Not sure whats going on attached is the result

enter image description here

How can I make UiImageView to follow constraints ?

3
  • It looks it is not [testPic]-19-[label]. Was there any constraint conflict warning? What happen if you set clipsToBounds on the image view? Commented Dec 6, 2016 at 19:29
  • I think you should use either Width and height or Top/Bottom/Left/Right. If you use both you will get a weird result there Commented Dec 6, 2016 at 19:43
  • Your constraints aren't fine as well. You're assigning the bottom constraint for both imageview and label. It will create conflicts. Commented Dec 6, 2016 at 21:42

1 Answer 1

1

Set clipsToBounds to true from the storyboard or you can also set it programmatically as:

imageView.clipsToBounds = true;

This will resolve your issue.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.