iOS8 ORIENTATION:调用supportedInterfaceOrientations但没有方向更改

时间:2015-02-13 11:21:13

标签: ios iphone ios8 orientation

我有一个导航控制器:

    //=========================
    - (BOOL)shouldAutorotate;
    {
        return YES;
    }

    - (NSUInteger)supportedInterfaceOrientations
    {
        NSLog(@"Nav: supported Orientation");     
        if ([[self topViewController] respondsToSelector:@selector(supportedInterfaceOrientations)])

       else
          return [super supportedInterfaceOrientations];
    }

    - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
    {
        [self.topViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation];
    }

    -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
        [self.topViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
    }

MY ROOTCTRL:

//=========================
- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight;
}

-(BOOL)shouldAutorotate
{
    return YES;
}

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
    NSString *risp;
    switch (self.interfaceOrientation) {
        case UIInterfaceOrientationLandscapeLeft:
            risp = @"LAND_LEFT";
            break;
        case UIInterfaceOrientationLandscapeRight:
            risp = @"LAND_RIGHT";
            break;
        case UIInterfaceOrientationPortrait:
            risp = @"PORT";
            break;
        case UIInterfaceOrientationPortraitUpsideDown:
            risp = @"PORT_UPsideDOWN";
            break;
        case UIInterfaceOrientationUnknown:
            risp = @"UNKNOW";
            break;
        default:
            break;
    }
    NSLog(@"HOME didRotate:%@",risp);
}

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{

}
始终调用UINavigationController的

supportedInterfaceOrientations ,也始终调用Home Controller的 supportedInterfaceOrientations ;但是Home不会从LANDSCAPE LEFT旋转到LANDSCAPE RIGHT,反之亦然:

所以Home ctrl在启动时有正确的方向,但是如果设备确实旋转了Home控制器从不旋转......它只被称为supportedInterfaceOrientations方法(导航控制器和根控制器),没有任何效果......

我做错了什么?

1 个答案:

答案 0 :(得分:1)

如果在iOS8上运行并且您的代码自iOS8之前就已存在,请检查以下答案。删除应用委托中提到的行(如果存在),它应该开始工作。

UISplitViewController rotation iOS8 not working as expected