在移动应用中判断横向和竖向方向的改变
2013-07-01 16:25
316 查看
在移动应用中,有时要判断用户把设备竖向变成横向时,页面必须做出必须的调整,在
apple系列的机器上,如ipad,iphone,itouch等,有一个属性可以判断:
window.onorientationchange = detectOrientation;
function detectOrientation(){
if(typeof window.onorientationchange != 'undefined'){
if ( orientation == 0 ) {
//Do Something In Portrait Mode
}
else if ( orientation == 90 ) {
//Do Something In Landscape Mode
}
else if ( orientation == -90 ) {
//Do Something In Landscape Mode
}
else if ( orientation == 180 ) {
//Do Something In Landscape Mode
}
}
}
而在其他类型的移动设备上,则可能要花点心思了,要通过其长,宽的改变去判断了,用jquery其实也可以实现的,比如:
$(document).ready(function(){
if ( window.orientation != undefined )
window.onorientationchange = updateView;
else
$(window).resize( updateView );
}
function updateView() {
//在这里编写字体,样式,颜色等的改变
}
apple系列的机器上,如ipad,iphone,itouch等,有一个属性可以判断:
window.onorientationchange = detectOrientation;
function detectOrientation(){
if(typeof window.onorientationchange != 'undefined'){
if ( orientation == 0 ) {
//Do Something In Portrait Mode
}
else if ( orientation == 90 ) {
//Do Something In Landscape Mode
}
else if ( orientation == -90 ) {
//Do Something In Landscape Mode
}
else if ( orientation == 180 ) {
//Do Something In Landscape Mode
}
}
}
而在其他类型的移动设备上,则可能要花点心思了,要通过其长,宽的改变去判断了,用jquery其实也可以实现的,比如:
$(document).ready(function(){
if ( window.orientation != undefined )
window.onorientationchange = updateView;
else
$(window).resize( updateView );
}
function updateView() {
//在这里编写字体,样式,颜色等的改变
}
相关文章推荐
- 在移动应用中,判断屏幕竖向或横向
- 移动应用滑动屏幕方向判断解决方案
- 移动应用滑动屏幕方向判断解决方案,JS判断手势方向
- 在protel、Altium中如何只改变引脚名的方向比如把竖向变成横向而引脚的方向不改变!!!
- 移动应用滑动屏幕方向判断解决方案,JS判断手势方向
- 向量叉积应用-判断鼠标移动方向
- 移动应用滑动屏幕方向判断解决方案
- 根据移动速度方向判断手势方向
- 一些有关Android图片的操作,判断方向,旋转,根据uri获取绝对路径,缩放与移动
- 优雅的判断scrollView的滑动方向(只适用一次手势中不改变滑动方向)
- Unity 点乘(Dot)、叉乘(Cross)判断移动方向、朝向等向量问题
- 改变Android屏幕默认启动方向为横向
- 从需求层次理论看移动应用的创意方向
- 移动应用跨平台开发技术方向对比
- 从需求层次理论看移动应用的创意方向
- 一款移动应用名叫Hailo-改变人们预订出租车的方式
- ios开发-判断手机方向改变
- 跨平台移动应用开发技术的方向控制
- 限制窗口只能在一个方向上移动或改变尺寸
- Swift - 判断设备方向(或监听设备方向的改变)