代码之家  ›  专栏  ›  技术社区  ›  Mihir Oza

从枚举类型“enum UIDeviceOrientation”隐式转换为不同的枚举类型“UIInterfaceOrientation“”枚举UIInterfaceOrientation

  •  9
  • Mihir Oza  · 技术社区  · 11 年前

    我正在使用Xcode 5.0.2,在尝试编译目标C代码时收到以下警告:

    从枚举类型“enum UIDeviceOrientation”隐式转换 到不同的枚举类型“UIInterfaceOrientation”(又名“enum” UI界面方向')

    警告显示在viewController.m中

    -(void)youTubeStarted:(NSNotification *)notification{
        // your code here
        NSLog(@"youTubeStarted");
        **[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait animated:NO];**
    }
    
    -(void)youTubeFinished:(NSNotification *)notification{
        // your code here
        NSLog(@"youTubeFinished");
    }
    
    - (void)youTubeVideoExit:(id)sender {
        **[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait animated:NO];**
    }
    
    1 回复  |  直到 11 年前
        1
  •  17
  •   hoiberg    11 年前

    这意味着您使用了错误的枚举类型:您使用了 UIDeviceOrientation 而不是 UIInterfaceOrientation . 要解决此问题,只需更换 UIDeviceOrientationPortrait 具有 UIInterfaceOrientationPortrait .