Using different modes such as "Scale To Fill", "Aspect Fit", "Aspect Fill" to control UIImageView inside UITableViewCell

I used UIImageView

internally UITableViewCell

and it will fill contentView. I tried another mode like "Scale To Fill", "Aspect Fit", "Aspect Fill" to pass the UIImageView inside the UITableViewCell. UIImageView inside UITableViewCell ends screen in Aspect Fill. I have set image limits as shown belowenter image description here

It works great as below

enter image description here

But when the image size is too large, it shows the problem as below. goes outside the cell

enter image description here

I have Aspect Fill

like below.

enter image description here

when i use Aspect Fit

i got this problem

enter image description here

When i use Scale To Fill

i got this problem

enter image description here

In Aspect Fit

and Scale To Fill

I got left and right box like above

below link doesn't address my problem so it doesn't duplicate

UIImageView inside UITableViewCell not updating

Resizing UIImageView inside UITableViewCell

iOS 8 - AutoLayout issue - UIImageView inside UITableViewCell ignores width constraints

+3


source to share


5 answers


You have a named option Clip subviews

in the table view cell. Make sure it is activated and it should be good.



+4


source


You need to enable subviews property for image, cell content image and cell. One more thing, I saw that by adding caps, you added margin caps. So, remove the old limits and add new limits with the margin limits disabled.



Let me know if it helps. :)

+1


source


As you describe All restrictions are set correctly.

Aspect Fill will draw everything inside the imageView while maintaining the aspect ratio of the image. If the image is larger than the image size, the image overflows. In such cases, you need to activate the "Clips subview" option in your ImageView's attribute inspector.

Go to your cellViewView attribute id in storyboard / xib. In the Draw section, select Clip Movements as True.

This will make the supervisor encrypted. In your case cellViewView is superview and imageView is subview.

+1


source


I think there is no problem in the cell, its in the Tableview.
Set limits on the Tableview that uses this cell.
It will work.

0


source


Set Width and Height Constraints for UIImageView

Remove other restrictions and set restrictions below for viewing images ...!

UIImageView --> Editor --> Pin --> Width

UIImageView --> Editor --> Pin --> Height

      

Cm

https://developer.apple.com/library/ios/recipes/xcode_help-IB_auto_layout/chapters/pin-constraints.html

Hope it fixes the problem ..!

0


source







All Articles