自定义单元格中的UIImageView无法正常工作

问题描述 投票:0回答:1

我已将UIImageView放在自定义单元格中,该自定义单元格只有该UIImageView作为其子视图。我添加了这些约束:

enter image description here

enter image description here

现在,我已经为ImageView及其容器(父级-内容视图)都设置了true的clipsToBounds。图像内容模式设置为适合的宽高比。但是,当我从cellForRowAt函数设置图像时,ImageView会忽略clipsToBounds和约束。我看到这是执行:enter image description here

如您所见,没有图像适合或设置约束。我在heightForRowAt函数中给出了行高,甚至还使用了estimatedHeightForRowAt函数。

swift uitableview uiimageview
1个回答
0
投票

事实证明,UITableViewCell中已经有一个名为imageView的ImageView,而我的自定义图像视图具有相同的名称。当我尝试在其中设置图像时,单元格的默认imageView得到了图像,而不是我自己的UIImageView。我将我的imageView的名称更改为ImgThumb,然后将图像放入其中,并且运行良好。

© www.soinside.com 2019 - 2024. All rights reserved.