UIWebview
当用户选择一个选项卡时,我有一个加载为子视图UISegmentedControl
.出于某种原因,我不能让它允许pinch/zooming
.我在viewDidLoad:
方法中设置了以下代码,因此它应该可以工作.
self.myWebView = [[[UIWebView alloc] initWithFrame:self.view.frame] autorelease]; self.myWebView.backgroundColor = [UIColor whiteColor]; self.myWebView.scalesPageToFit = YES; self.myWebView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight); self.myWebView.delegate = self; [self.view addSubview: myWebView];
我尝试UIWebView
从NIB 加载并以编程方式创建它无济于事.有什么我想念的吗?什么可能导致webview忽略捏和缩放?
谢谢!
[webView stringByEvaluatingJavaScriptFromString:@"document.body.style.zoom = 5.0;"];
似乎是合适的解决方案
我通过设置视口解决了这个问题:
- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { //make sure that the page scales when it is loaded :-) theWebView.scalesPageToFit = YES; return YES; }我对文档的解释是scalesPageToFit属性决定了如何加载页面.事后并没有改变事情.
希望这可以帮助.