应用程序启动后iPad应用程序界面方向更改

时间:2013-11-08 05:44:26

标签: ios ipad ios7 orientation uiinterfaceorientation

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

enter image description here

5 个答案:

答案 0 :(得分:1)

如果您希望我们的所有导航控制器都尊重顶视图控制器,您可以使用类别,这样您就不必经历并更改一堆类名。

 @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。

答案 1 :(得分:1)

enter image description here

您必须在构建设置中设置方向,请参阅图像。

它将解决您的问题。

答案 2 :(得分:0)

试试这个:

- (BOOL)shouldAutorotate
{
    return YES;
}

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

编辑:

查看随附的link,可能对您有所帮助。

答案 3 :(得分:0)

我找到解决方案,我所做的是。 第一步 通过创建类别

覆盖我的UInavigationcontroller 第二步 更换 [self.window addSubview:[navigationController view]]; // OLD

使用 [self.window setRootViewController:navigationController]; // NEW

答案 4 :(得分:0)

在Appdelegate.m中使用它

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

        return UIInterfaceOrientationMaskLandScape;
    }
    else{
        return UIInterfaceOrientationMaskPortrait;
    }
}

它帮助了我......