我有一些base64數據,並試圖把它放在我的圖像,我可以做但我無法得到它,因此它縮小到只填充imageView,而不是使它更大,這裏是我在做什麼圖像不適合UIImageView
NSString *base64 =[[NSString stringWithFormat:@"data:image/png;base64,%@", dataString] stringByReplacingOccurrencesOfString:@" " withString:@"+"];
NSURL *url = [NSURL URLWithString:base64];
NSData *imageData = [NSData dataWithContentsOfURL:url];
UIImage *image = [UIImage imageWithData:imageData];
rdCell.imageView.clipsToBounds = YES;
rdCell.imageView.contentMode = UIViewContentModeScaleAspectFill;
[rdCell.imageView setImage:image];
我也試過這種
NSURL *url = [NSURL URLWithString:base64];
NSData *imageData = [NSData dataWithContentsOfURL:url];
UIImage *image = [UIImage imageWithData:imageData];
rdCell.imageView.contentMode = UIViewContentModeScaleAspectFit;
[rdCell.imageView setImage:image];
但後來我看到圖像比圖像視圖的原始尺寸大,爲什麼不會它留在裏面?
謝謝
是什麼rdCell?告訴我們你在哪裏分配imageView? –
@SamB rdCell是我的UITableViewCell包含圖像視圖,我將發佈更多關於它上面 – spenf10