我一直在處理這個問題,通過圍繞它的工作了一段時間,但我真的想知道的辦理情況的正確方法: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