我已经UIImageView在里面使用了UITableViewCell它将填充contentView.我已经尝试了不同的模式,如"Scale To Fill","Aspect Fit","Aspect Fill"到UITableViewCell里面的UIImageView.UITmageView里面的UIImageView已经用完了屏幕. Aspect Fill.我为图像设置了约束,如下所示
它工作正常如下
但是当图像尺寸太大时,它会显示出下面的问题,即它超出了单元边界

我使用
Aspect Fill如下图所示

当我使用时,
Aspect Fit我遇到了这个问题

当我使用时,
Scale To Fill我遇到了这个问题

在
Aspect Fit和Scale To Fill我的左边和右边有余量如上图所示下面的链接不解决我的问题所以它不重复
UITableViewCell中的UIImageView没有得到更新
我正在尝试将图像设置UIImageView为a SimpleTableCell中的a UITableView.我已经改变了imageview的大小,但每当我尝试设置图像时,它会自动调整大小.我尝试使用此处的代码来调整图像大小并进行设置.但它仅在我将图像尺寸设置为(20x20)时才有效,该尺寸是UIImageView(40x40)尺寸的一半.所以它模糊了.我也试过设置UIAspectRatioFit/UIAspectratioFill和clipsToBounds = YES.似乎没什么用.
另一个奇怪的部分是,imageView当我使用直接从网上下载的图像时,它不会自行调整大小:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
UIImage *userImage = [UIImage imageWithData:userImageData scale:self.profileImage.frame.size.height/self.profileImage.frame.size.width];
UITableViewCell *cell = [self.myTable cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
cell.imageView.image = userImage;
}
Run Code Online (Sandbox Code Playgroud)
但随后我将此图像存储到文档目录中,然后尝试在其他地方重新加载,进行大小调整.有解决方案吗