[英]stringByEvaluatingJavaScriptFromString callback
i have WebView load html. 我有WebView加载html。 after scale html 后规模html
-(void)webViewDidFinishLoad:(UIWebView *)webView
{
[self setupContentScale];
self.webView.hidden = NO;
[self setLoadingIndicatorVisible:NO];
}
scale metods 刻度尺
- (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];
}
but i have Show indicator while html scale or callback metod and 但我有显示指标,而html缩放或回调方法和
self.webView.hidden = NO;
[self setLoadingIndicatorVisible:NO];
how get callback? 如何获得回调?
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...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.