我有WebView加载HTML。在缩放html之后
-(void)webViewDidFinishLoad:(UIWebView *)webView
{
[self setupContentScale];
self.webView.hidden = NO;
[self setLoadingIndicatorVisible:NO];
}
比例方法
- (void)setupContentScale
{
CGFloat scaleFactor = self.webView.bounds.size.width / self.webView.scrollView.contentSize.width;
if (scaleFactor != DEFAULT_WEBVIEW_SCALE_FACTOR) {
scaleFactor -= 0.2f; // to be sure that page will be scaled to required size
[self.webView setScalesPageToFit:NO];
[self.webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"document.body.style.zoom = %f;", scaleFactor]];
}
[self updateFontSize];
[self updateLineHeight];
[self updateContentWidth];
}
但我有html比例显示指标 或回调方法和
self.webView.hidden = NO;
[self setLoadingIndicatorVisible:NO];
如何获得回调?
答案 0 :(得分:1)
NSString *StrParameter=@"Test Parameter"
NSString *Str= [NSString stringWithFormat:@"var c = '%@',StrParameter];
[myWebView stringByEvaluatingJavaScriptFromString:Str];
NSString *newStringFinal = [myWebView stringByEvaluatingJavaScriptFromString:@"function final(){ return c; } final();"];
NSLog(@"RESULT STRING: %@",newStringFinal);
// Here newStringFinal has Callback value which have current value of Variable 'c' in javascript...