我正在使用应用程序。应用程序的方向是景观,但是在应用程序运行接口方向后,应用程序更改接口并旋转。以正确的方式显示屏幕屏幕(风景)。我正在使用ios7该应用程序是iOS5的代码,我认为有一些不弃用的API问题,例如,apeautorotateTototatoInterfaceorientation bot称为dame,因为在最新iOS中不再可用

enter image description here

有帮助吗?

解决方案

如果您希望我们所有的导航控制器尊重顶视图控制器,则可以使用类别,因此您不必经过并更改一堆类名称。

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

其他提示

enter image description here

您必须在构建中设置Orintatoin,请参见图像。

它将解决您的问题。

尝试这个:

- (BOOL)shouldAutorotate
{
    return YES;
}

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

编辑 :

请参阅附件 关联, ,可能对您有帮助。

我发现解决方案的想法是我所做的。第一步通过创建一个类别来覆盖我的uinavigation controller

步骤二替换[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;
    }
}

它帮助了我..

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top