Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 如何在mac上检测屏幕旋转?_Macos_Cocoa_Rotation_Screen_Orientation - Fatal编程技术网

Macos 如何在mac上检测屏幕旋转?

Macos 如何在mac上检测屏幕旋转?,macos,cocoa,rotation,screen,orientation,Macos,Cocoa,Rotation,Screen,Orientation,是否可以检测屏幕旋转?我正在研究mac上的触摸屏驱动程序,所以我想知道屏幕是否旋转。MacBooks(和ThinkPad)有一个加速计,用于检测突然移动(即掉落)以防止HD磁头碰撞。加速计数据通过webkit API公开 用于加速计数据的本机API仅通过专用于苹果的接口公开,但阿米特·辛格(Amit Singh)已经发布了他的突发运动传感器API文档 请注意,他已经发布了一个免费的程序,名为SMSRotateD,可以做你想做的事情。当您翻转设备时,它会旋转MacBook屏幕。还有一个很酷的示例,

是否可以检测屏幕旋转?我正在研究mac上的触摸屏驱动程序,所以我想知道屏幕是否旋转。

MacBooks(和ThinkPad)有一个加速计,用于检测突然移动(即掉落)以防止HD磁头碰撞。加速计数据通过webkit API公开

用于加速计数据的本机API仅通过专用于苹果的接口公开,但阿米特·辛格(Amit Singh)已经发布了他的突发运动传感器API文档


请注意,他已经发布了一个免费的程序,名为SMSRotateD,可以做你想做的事情。当您翻转设备时,它会旋转MacBook屏幕。还有一个很酷的示例,它有一个“陀螺”窗口,当您随机倾斜设备时,该窗口将保持在顶部。

希望此HTML将有所帮助(以下为工作版本)

还有,你可以查一下。他们还提供一个工作图书馆

<html>
<head>

<style>

.angle { height: 100px; } 
#alpha { background-color: red; } 
#beta { background-color: green; } 
#gamma { background-color: blue; } 

</style>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

<script>

var set_bar = function( id, value ) {
  var max_width = $(window).width();
  $( id ).width( value * max_width );
}

var normalize_angle = function( deg ) {
  var x = ( (deg + 180) / 360 ) % 1.0;
  return (x < 0) ? (x + 1.0) : x;

}

window.addEventListener("deviceorientation", function(event) {
  set_bar( "#alpha", normalize_angle(event.alpha));
  set_bar( "#beta", normalize_angle(event.beta + 180));
  set_bar( "#gamma", normalize_angle(event.gamma));
}, true);

</script>
</head>
<body>

  <div class="angle" id="alpha">&nbsp;</div>
  <div class="angle" id="beta">&nbsp;</div>
  <div class="angle" id="gamma">&nbsp;</div>

</body>
</html>

.角度{高度:100px;}
#alpha{背景色:红色;}
#β{背景色:绿色;}
#gamma{背景色:蓝色;}
var set_bar=函数(id,值){
var max_width=$(窗口).width();
$(id).宽度(值*最大宽度);
}
var规格化角度=函数(度){
var x=((度+180)/360)%1.0;
回报率(x<0)-(x+1.0):x;
}
window.addEventListener(“设备定向”,函数(事件){
设置_条(“#alpha”),规范化_角度(event.alpha));
设置#u条(“#beta”,标准化#u角度(event.beta+180));
设置_条(“#gamma”,规格化_角度(event.gamma));
},对);

谢谢您的回复!我已经用计算机解决了这个问题。但你的答案是伟大的旋转屏幕的硬件。再次感谢!