Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/37.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
Ios ViewController方向与状态栏不一致_Ios_Iphone_Objective C_Ios7_Ios7 Statusbar - Fatal编程技术网

Ios ViewController方向与状态栏不一致

Ios ViewController方向与状态栏不一致,ios,iphone,objective-c,ios7,ios7-statusbar,Ios,Iphone,Objective C,Ios7,Ios7 Statusbar,我的应用程序有这样一个主要结构:UITabBarController,每个选项卡上都有一个UINavigationController,它根据用户交互推送视图。除了一些特定的部分外,几乎所有的应用程序都是纵向的 我想要的行为是,当我按下其中一个部分(比如地图)时,具有横向方向。在该地图中,用户可以返回到纵向。当他回到主菜单时,他应该回到纵向(此处不允许横向)。我不介意他是否暂时在风景区 下面是我的UITabBarController子类中的一些代码: - (BOOL)shouldAutorota

我的应用程序有这样一个主要结构:UITabBarController,每个选项卡上都有一个UINavigationController,它根据用户交互推送视图。除了一些特定的部分外,几乎所有的应用程序都是纵向的

我想要的行为是,当我按下其中一个部分(比如地图)时,具有横向方向。在该地图中,用户可以返回到纵向。当他回到主菜单时,他应该回到纵向(此处不允许横向)。我不介意他是否暂时在风景区

下面是我的UITabBarController子类中的一些代码:

- (BOOL)shouldAutorotate
{
    return [self.selectedViewController shouldAutorotate];
}

- (NSUInteger)supportedInterfaceOrientations
{
    return [self.selectedViewController supportedInterfaceOrientations];
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return [self.selectedViewController preferredInterfaceOrientationForPresentation];
}
我在UINavigationController中使用相同的代码,在特定菜单中,我有以下内容:

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}

- (BOOL)shouldAutorotate
{
    if (!UIInterfaceOrientationIsPortrait([[UIDevice currentDevice] orientation]))
        return NO;

    return YES;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
}
这种行为几乎一直在起作用。当菜单方向为横向且用户旋转其设备时,他会返回到纵向,但不能返回到横向

我的问题是:状态栏偶尔会旋转,但视图控制器不会旋转。(参见图片)每次调用
shouldAutorotate
并返回正确的值(即,它返回YES但不自动旋转)

我知道这是在扩展SDK,但我希望一直都能做到这一点。有什么提示吗


我也有同样的问题。你找到解决办法了吗?我最终选择了另一个方向。当用户在地图的ViewController中旋转设备时,此问题不会发生(请参阅OP中的示例)。因此,我添加了一个视图,其中有一个图标(位于地图顶部),要求他旋转设备。该视图只会随着设备旋转而消失。。。这样一来,问题就不再出现了。我正在构建的这个应用程序不是为AppStore设计的,所以我不关心指导原则。对不起,我没有更好的解决办法。。。