检测设备颠倒的正确值是什么?颠倒检测设备
我有以下几点,它开始检测用户标题背面的设备。
我使用下列值
float xx = -[acceleration x];
float yy = [acceleration y];
float angle = atan2(yy, xx);
if(angle >= 0.75 && angle <= 2.25)
{
NSLog(@"Upside down");
}
检测设备颠倒的正确值是什么?颠倒检测设备
我有以下几点,它开始检测用户标题背面的设备。
我使用下列值
float xx = -[acceleration x];
float yy = [acceleration y];
float angle = atan2(yy, xx);
if(angle >= 0.75 && angle <= 2.25)
{
NSLog(@"Upside down");
}
开始利用监听定位事件:
UIDevice *currDevice = [UIDevice currentDevice];
[currDevice beginGeneratingDeviceOrientationNotifications];
然后,用得到的方位:
currDevice.orientation
这些返回的值:
{ '1': 'Portrait', '2':'PortraitUpsideDown', '3':'LandscapeLeft', '4':'Landsc apeRight”, ‘5’:‘面朝上’, ‘6’:‘面朝下’}
所以在你的情况,你会想听currDevice.orientation是6 – JCox
我必须得到的方向== 2.谢谢,这帮助我解决它。 – user773578
很高兴我能帮上忙! – JCox
详情请参阅 '设备取向' 的一部分。
不要试图在这里推倒重来。这在UIDevice API中有记录。 –