UIWebView content not scaling between different iPhone sizes(UIWebView 内容不能在不同 iPhone 尺寸之间缩放)
问题描述
所以我正在开发一个使用 UIWebView 来提供 HTML 内容的 iOS 应用程序.为什么是 UIWebView 而不是 WKWebView?好吧,我希望这个应用程序可以在 iOS7 及更高版本上运行.我刚刚将我的 Xcode 更新为 Xcode 6.1,当从 4 英寸屏幕尺寸更改为 4.7 及以上时,我无法让我的 webView 缩放以适应可用的屏幕空间.
So I am working on an iOS app that uses the UIWebView to serve HTML content. Why UIWebView and not WKWebView? well I want this app to work on iOS7 and above. I have just updated my Xcode to Xcode 6.1 and I cannot get my webView to scale to fit the available screen space when changing from the 4 inch screen size to 4.7 and above.
我所追求的是让我的应用程序在所有 4 英寸及以上的 iPhone 屏幕尺寸上看起来一致,就像我在 Web 视图上显示的所有 HTML5 代码一样.
What I am after is to have my app look consistent on all iPhone screen sizes of 4 inch and above as all my HTML5 code that is displayed on the web view is.
在我的属性检查器中,我已将尺寸设置为 iPhone 4 英寸,您可以在下面的链接中分别看到该应用在 4 英寸和 4.7 英寸 iPhone 模拟器中的外观,http://imgur.com/gallery/tz7LG/new
In my Attributes inspector I have set the size to iPhone 4-inch and you can see what the app looks like in simulators for iPhones of size 4-inch and 4.7-inch respectively in the link below, http://imgur.com/gallery/tz7LG/new
如何让它在不同尺寸的 iPhone 屏幕上适当放大?
How do I get this to scale up appropriately on iPhone screens of different sizes?
fyi,我已将我的 webView 的缩放"页面设置为适合".我正在使用 Swift 构建这个应用程序.
fyi, I have set the Scale page to Fit to true for my webView. I am building this app using Swift.
推荐答案
请检查您是否没有在 .m 文件中编码维度.
Do check that you haven't coded the dimensions in the .m file.
Piyush Mathur 的答案很简单,在给定的情况下似乎很有用.
The answer by Piyush Mathur is simple and seems usable in the given case.
但如果需求复杂,则需要使用自动布局".
But if the requirements are complex then you need to "Use Auto Layout".
还要确保您已设置 Web 视图所需的所有约束.
Also make sure that you have set all the needed constraints of the Web-View.
Introduction to Auto-Layout 提供了设置约束的想法组件,它还可以根据设备屏幕尺寸提供拉伸组件(在您的情况下为 Web 视图)的想法.
The Introduction to Auto-Layout gives an idea to set constraints to a component which will also give an idea to stretch component (Web-view in your case) based on the device screen size.
这篇关于UIWebView 内容不能在不同 iPhone 尺寸之间缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:UIWebView 内容不能在不同 iPhone 尺寸之间缩放
基础教程推荐
- 如何使 UINavigationBar 背景透明? 2022-01-01
- 在 iOS 上默认是 char 签名还是 unsigned? 2022-01-01
- :hover 状态不会在 iOS 上结束 2022-01-01
- LocationClient 与 LocationManager 2022-01-01
- 如何使用 YouTube API V3? 2022-01-01
- Android文本颜色不会改变颜色 2022-01-01
- “让"到底是怎么回事?关键字在 Swift 中的作用? 2022-01-01
- 固定小数的Android Money Input 2022-01-01
- 使用 Ryzen 处理器同时运行 WSL2 和 Android Studio 2022-01-01
- Android ViewPager:在 ViewPager 中更新屏幕外但缓存的片段 2022-01-01
