如何在 iPhone Web 应用程序中将方向锁定为纵向模式?
我正在构建一个 iPhone Web 应用程序并希望将方向锁定为纵向模式.这可能吗?是否有任何网络工具包扩展可以做到这一点?
I'm building a iPhone Web Application and want to lock the orientation to portrait mode. is this possible? Are there any web-kit extensions to do this?
请注意,这是为 Mobile Safari 用 HTML 和 JavaScript 编写的应用程序,它不是用 Objective-C 编写的本机应用程序.
Please note this is an application written in HTML and JavaScript for Mobile Safari, it is NOT a native application written in Objective-C.
您可以根据视口方向指定 CSS 样式:使用 body[orient="landscape"] 或 body[orient="portrait"]
You can specify CSS styles based on viewport orientation: Target the browser with body[orient="landscape"] or body[orient="portrait"]
http://www.evotech.net/blog/2007/07/web-development-for-the-iphone/
不过……
Apple 解决此问题的方法是允许开发人员根据方向更改更改 CSS,但不能完全阻止重新定位.我在别处发现了类似的问题:
Apple's approach to this issue is to allow the developer to change the CSS based on the orientation change but not to prevent re-orientation completely. I found a similar question elsewhere:
http://ask.metafilter.com/99784/How-can-I-lock-iPhone-orientation-in-Mobile-Safari