Ios APLICITON发布后,iPad应用程序界面方向发生变化

Ios APLICITON发布后,iPad应用程序界面方向发生变化,ios,ipad,ios7,orientation,uiinterfaceorientation,Ios,Ipad,Ios7,Orientation,Uiinterfaceorientation,我正在开发应用程序。应用程序的方向是横向的,但在应用程序运行后,应用程序的界面方向会更改界面并旋转。启动屏幕显示方式正确(横向)。 我使用的是ios7。应用程序是ios5的代码。我认为存在一些不推荐使用的api问题,例如,应该调用AutoRotateTointerFaceOrientation bot,因为这在最新的ios中不再可用 试试这个: - (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfa

我正在开发应用程序。应用程序的方向是横向的,但在应用程序运行后,应用程序的界面方向会更改界面并旋转。启动屏幕显示方式正确(横向)。 我使用的是ios7。应用程序是ios5的代码。我认为存在一些不推荐使用的api问题,例如,应该调用AutoRotateTointerFaceOrientation bot,因为这在最新的ios中不再可用

试试这个:

- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
编辑:


请参阅附件,可能会对您有所帮助。

如果您希望我们的所有导航控制器都尊重俯视图控制器,您可以使用一个类别,这样您就不必查看和更改大量类名

 @implementation UINavigationController (Rotation_IOS6)

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

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

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return [[self.viewControllers lastObject]     preferredInterfaceOrientationForPresentation];
}

@end
正如一些评论所指出的,这是一个快速解决问题的方法。更好的解决方案是子类UINavigationController,并将这些方法放在那里。子类也有助于支持6和7。

您必须在查看图像的内部版本中设置orintatoin


这会解决你的问题。

我找到了我所想的解决办法。 第一步 通过创建类别覆盖我的UInavigationcontroller

第二步 代替 [self.window addSubview:[navigationController视图]]//旧的


[self.window setRootViewController:navigationController]//新建

在Appdelegate.m中使用此选项

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    NSLog(@"Interface orientations");
    if([[UIDevice currentDevice]userInterfaceIdiom]==UIUserInterfaceIdiomPad ){

        return UIInterfaceOrientationMaskLandScape;
    }
    else{
        return UIInterfaceOrientationMaskPortrait;
    }
}

这对我很有帮助。

你想在横向视图中显示此视图吗?是的,当你使用时,我的应用方向会旋转,但模拟器处于横向模式。我的应用程序还用于在属性检查器中检查XIB视图的景观方向。这是您的第一个视图吗?我的应用程序仅适用于iOS 7