如何在 iPhone Web 应用程序中将方向锁定为纵向模式? [英] How do I lock the orientation to portrait mode in a iPhone Web Application?

查看:29
本文介绍了如何在 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

这篇关于如何在 iPhone Web 应用程序中将方向锁定为纵向模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆