Ios7 当设备平放在桌子上时,WillRotateToInterface定向不起作用

Ios7 当设备平放在桌子上时,WillRotateToInterface定向不起作用,ios7,rotation,device,Ios7,Rotation,Device,我使用这段代码检测方向的变化,并由此切换视图: -(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) { [self performSegueWithIdentif

我使用这段代码检测方向的变化,并由此切换视图:

-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
    [self performSegueWithIdentifier:@"PORTADA-PORTADAH" sender:self];
    }
else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
    [self performSegueWithIdentifier:@"PORTADA-PORTADAH" sender:self];
    }
else if (toInterfaceOrientation == UIInterfaceOrientationPortrait) {
    nil;
    }
else if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
    nil;
    }
}

它工作得很好,但是当设备平放在桌子上时,它根本不工作。这只是一个将设备(ipad)提升15或20度的问题,但我的雇主对此并不满意


有什么想法吗?

当设备与地面平行时,它不会调用4个方向中的任何一个。或者平躺在桌子上。它将称为“面向上”和“面向下”方向。通过使用以前的方向,我们需要使用最新的正面朝上和正面朝下的方向来管理原点。

只有当陀螺仪检测到重力矢量的差异时,iOS中的界面方向才会改变。当设备平放时,即使绕y轴旋转,也无法知道用户相对于设备的位置。当重力矢量发生变化时,假定用户与该矢量平行,因此很容易猜测


TL;DR-不太可能。

雇主期望有什么行为?你需要添加更多的细节。有
UIDeviceOrientation
,有硬件传感器可以使用。但是你需要提供更多的细节。谢谢你,利奥。预计当设备平放在工作台上时,方向变化的效果与提升时相同。你需要什么细节?此代码位于每个具有纵向方向的视图控制器中,它所做的是执行到等效lanscape方向视图的转换。我甚至不确定这是否可行。当设备为平面时,无法知道用户相对于设备的位置。当陀螺仪检测到重力矢量的差异时,界面方向会发生变化。好吧,那么我想要说服他。。。谢谢你,让老板相信不可能的需求总是一个问题对不起,玛杜,我不明白你的答案。