即使将 scalesPageToFit 设置为 YES,UIWebview 也不会缩放

UIWebview won#39;t zoom even after setting scalesPageToFit to YES(即使将 scalesPageToFit 设置为 YES,UIWebview 也不会缩放)

本文介绍了即使将 scalesPageToFit 设置为 YES,UIWebview 也不会缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户选择 UISegmentedControl 上的选项卡时,我有一个 UIWebview 作为子视图加载.出于某种原因,我无法让它允许 pinch/zooming.我在 viewDidLoad: 方法中设置了以下代码,所以它应该可以工作.

I have a UIWebview that is loaded as a subview when a user selects a tab on a UISegmentedControl. For some reason, I can not get it to allow pinch/zooming. I set the following code in the viewDidLoad: method, so it should work.

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];

我尝试从 NIB 加载 UIWebView 并以编程方式创建它,但无济于事.有什么我想念的吗?什么可能导致 webview 忽略捏合和缩放?

I tried loading a UIWebView from a NIB and creating it programmatically with no avail. Is there something I'm missing? What could be causing the webview to ignore pinching and zooming?

谢谢!

推荐答案

我看到你正在设置 autoresizingMask.这是否意味着您已经创建了初始大小为 CGRectZeroUIWebView ?您可以与文档进行交互吗?我的意思是,滚动/点击有效吗?

I see you are setting the autoresizingMask. Does that mean you have created the UIWebView with an initial size of CGRectZero ? Can you interact with the document at all? I mean, does scrolling/tapping work?

这篇关于即使将 scalesPageToFit 设置为 YES,UIWebview 也不会缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:即使将 scalesPageToFit 设置为 YES,UIWebview 也不会缩放

基础教程推荐