我一直在处理这个问题,通过围绕它的工作了一段时间,但我真的想知道的办理情况的正确方法:UIImages没有履行UIViewContentMode
如果我得到的图像作为NSData的从CoreData像这样:
NSData *myImageData = myEntity.Image;
cell.imageView.image = [UIImage imageWithData:myImageData];
[cell.imageView setContentMode:UIViewContentModeScaleAspectFit];
如果图像比的UIImageView的的CGRect越大,图像本身并不约束到的UIImageView的的CGRect。
我目前做来解决使用代码的问题是这样的:
CGSize size = CGSizeMake(98, 98);
UIGraphicsBeginImageContext(size);
[image drawInRect:CGRectMake(0, 0, size.width, size.height)];
UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
cell.imageView.image = scaledImage;
其中一期工程,但我当然希望有人告诉我,我在做什么毛病ContentMode方法,因为它应该工作。
感谢您花时间阅读我的问题。
不知道这是否对方案有任何影响,但我正在尝试从UITableViewCell内部执行此操作 – 2012-02-25 15:44:29
您是否设法解决了这个问题? – 2013-11-23 22:59:51