I have used UIImageView
inside the UITableViewCell
and it will fill the contentView.I have try different mode like "Scale To Fill","Aspect Fit",""Aspect Fill" to handell UIImageView inside UITableViewCell. UIImageView inside UITableViewCell is running out of the screen in Aspect Fill. I have set constraints for the image as shown below
It works fine as below
But when image size is too large it shows problem as below that it goes outside the cell boundary
I have use
Aspect Fill
as shown below image
when I use
Aspect Fit
I got this problem
When I use
Scale To Fill
I got this problem
In
Aspect Fit
andScale To Fill
I got margin in left and right as shown abovebelow link doesnt address my problem so its not duplicate
UIImageView inside UITableViewCell does not get updated
Resizing UIImageView inside a UITableViewCell
iOS 8 - AutoLayout issue - UIImageView inside UITableViewCell ignoring width constraints
You have an option named Clip subviews
on your table view cell. Check that it's activated, and it should be good.
As per your description Your constraints are all set correct.
Aspect Fill will draw the entire inside the imageView by maintaining the image's aspect ratio. If the image is larger than the imageView's dimension the image overflows. In such cases you need to activate the "Clips subview" option in the attribute inspector of your imageView.
Go to your cell's imageView attribute inspector in storyboard/xib. Under the "Drawing" section choose "Clips subviews" as true.
This will make the superView clip its subviews. In your case cell's contentView is the superView and imageView the subview.
You need to enable clip subviews property for imageview, cell's contentview and cell. One more thing, I saw that while you added constraints, you added constraints with margin.. So, remove old constraints and add again new constraints with disabling Constraints to margin..
Let me know if it helps. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With