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 也不会缩放
基础教程推荐
- Android ViewPager:在 ViewPager 中更新屏幕外但缓存的片段 2022-01-01
- Android文本颜色不会改变颜色 2022-01-01
- “让"到底是怎么回事?关键字在 Swift 中的作用? 2022-01-01
- 如何使 UINavigationBar 背景透明? 2022-01-01
- :hover 状态不会在 iOS 上结束 2022-01-01
- 固定小数的Android Money Input 2022-01-01
- 在 iOS 上默认是 char 签名还是 unsigned? 2022-01-01
- 使用 Ryzen 处理器同时运行 WSL2 和 Android Studio 2022-01-01
- 如何使用 YouTube API V3? 2022-01-01
- LocationClient 与 LocationManager 2022-01-01
