要重置UIWebView的缩放,您可以使用以下方法:
- (void)webViewDidFinishLoad:(UIWebView *)webView {
[webView stringByEvaluatingJavaScriptFromString:@"document.body.style.zoom = 1.0;"];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
[webView stringByEvaluatingJavaScriptFromString:@"document.body.style.zoom = 1.0;"];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
[webView stringByEvaluatingJavaScriptFromString:@"document.body.style.zoom = 1.0;"];
}
- (IBAction)resetZoom:(id)sender {
[self.webView stringByEvaluatingJavaScriptFromString:@"document.body.style.zoom = 1.0;"];
}
这样,您就可以在不同的场景下重置UIWebView的缩放了。
领取专属 10元无门槛券
手把手带您无忧上云