【发布时间】:2015-07-29 20:35:55
【问题描述】:
我在UITableViewCell 中使用了UIImageView,它将填充contentView。我尝试了不同的模式,如“缩放填充”、“Aspect Fit”、“Aspect Fill”来处理UITableViewCell 中的UIImageView。UIImageView UITableViewCell 内部在 Aspect Fill 中超出屏幕。我为图像设置了约束,如下所示
它可以正常工作,如下所示
但是当图像尺寸太大时,它会显示如下问题 超出单元格边界
我使用
Aspect Fill,如下图所示
当我使用
Aspect Fit时,我遇到了这个问题
当我使用
Scale To Fill时,我遇到了这个问题
在
Aspect Fit和Scale To Fill中,我的左右边距为 如上所示下面的链接没有解决我的问题,所以它不重复
UIImageView inside UITableViewCell does not get updated
Resizing UIImageView inside a UITableViewCell
iOS 8 - AutoLayout issue - UIImageView inside UITableViewCell ignoring width constraints
【问题讨论】:
-
您是否尝试过设置 UIImageView 的不同模式,例如“Scale To Fill”、“Aspect Fit”、“Aspect Fill”等?
-
是的,正确!!! @iPhone
-
我用过方面填充
-
请尝试其他 UIImageView 模式!!
-
您需要为 imageview、cell 的 contentview 和 cell 启用 clips to bounds 属性。我看到在添加约束时,您使用边距设置它。因此,删除旧约束并再次使用禁用约束到边距的新约束。如果有帮助,请告诉我。 :)
标签: ios objective-c uitableview uiimageview autolayout