我像这样加载Gif图像
[webView2 loadData:[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Apple_jumps" ofType:@"gif"]] MIMEType:@"image/gif" textEncodingName:nil baseURL:nil];
我想设置uiwebview的中心位置,但我无法获得内容的宽度。请帮忙。
答案 0 :(得分:0)
您可以使用javascript中的document.height
或document.width
// in init
_WebView.delegate = YourClass; // probably self
- (void) webViewDidFinishLoad:(UIWebView *)webview
{
int w = [[_WebView stringByEvaluatingJavaScriptFromString:@"document.width"] floatValue];
_WebView.userInteractionEnabled = w > 200;
}
此处有更多信息:https://www.albertopasca.it/whiletrue/objective-c-get-uiwebview-html-page-size/