UIWebview won#39;t zoom even after setting scalesPageToFit to YES(即使将 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.这是否意味着您已经创建了初始大小为 CGRectZero 的 UIWebView ?您可以与文档进行交互吗?我的意思是,滚动/点击有效吗?
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 也不会缩放
基础教程推荐
- 如何从 logcat 中删除旧数据? 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
