需要解决这个问题,我们可以在loadHTMLString的时候加入css语句,拼接需要加载的内容
//html是需要加载的内容
- (NSString *)autoWebAutoImageSize:(NSString *)html{
return [NSString stringWithFormat:@"<html><head><meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0'><style>*{ width: 100%%; margin: 0; padding: 0 3; box-sizing: border-box;} img{ width: 100%%;}</style></head><body>%@</body></html>", html];
}
调用
[self.webView loadHTMLString:[self autoWebAutoImageSize:content] baseURL:nil];