我一直在尝试使用一种常用来调整图像大小的方法。不使用此方法,这里是获取图像 url 的代码。
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data];
cell.imageView.image = img;
这工作正常。但是当我尝试使用这种方法时:
-(UIImage*)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize;
{
UIGraphicsBeginImageContext( newSize );
[image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
并使用它来调用它:
UIImage *scaledImage = [self imageWithImage:img scaledToSize:CGSizeMake(10.0f,10.0f)];
然后像这样放入我的桌子:
cell.imageView.image = scaledImage;
什么都没有出现。我在这里缺少什么吗?