我有一张我在UIWebView中加载的图片。我已将scaleToFit设置为webView的YES。它仍然没有扩展到webView的屏幕。
只有当我在iOS 10.3.1上运行它时才会发生这种情况。它适用于旧版本。
self.webView.scalesPageToFit = YES;
答案 0 :(得分:0)
您是否对图像施加了任何限制?它可能与设备大小而不是iOS版本有关吗?
只是一个想法,可能是完全错误的......
答案 1 :(得分:0)
我可以问你为什么首先将图像加载到UIWebView中?
我建议尽可能使用UIImageView。有了这个,你可以设置它" contentMode"到你喜欢的设置。如果您需要一种方法来加载远程图像,请查看这个非常受欢迎的图像。易于使用的库: https://github.com/rs/SDWebImage
使用上面的库加载远程图像就像这样简单:
[[SDWebImageDownloader sharedDownloader] downloadImageWithURL:[NSURL URLWithString:iconURL] options:SDWebImageDownloaderHighPriority progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
} completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
dispatch_async(dispatch_get_main_queue(), ^{
[yourImageView setImage:image];
});
}];