【问题标题】:Implicit conversion from enumeration type 'enum UIDeviceOrientation' to different enum type 'UIInterfaceOrientation' 'enum UIInterfaceOrientation从枚举类型'enum UIDeviceOrientation'到不同枚举类型'UIInterfaceOrientation'的隐式转换'enum UIInterfaceOrientation
【发布时间】:2014-09-12 09:04:12
【问题描述】:

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

从枚举类型'enum UIDeviceOrientation'隐式转换 到不同的枚举类型'UIInterfaceOrientation'(又名'enum UIInterfaceOrientation')

警告在 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];**
}

【问题讨论】:

  • 使用“UIInterfaceOrientationPortrait”而不是“UIDeviceOrientationPortrait”
  • - (void)setStatusBarOrientation:(UIInterfaceOrientation)interfaceOrientation animated:(BOOL)animated
  • 感谢@EDUsta 成功了。
  • @EDUsta 请发表您的评论作为答案,以便我接受答案。
  • hoiberg42 有同样的答案,你也可以接受。快乐的编码:)

标签: ios objective-c xcode notifications uiinterfaceorientation


【解决方案1】:

这意味着你使用了错误的枚举类型:你使用了UIDeviceOrientation 而不是UIInterfaceOrientation。 要解决此问题,只需将 UIDeviceOrientationPortrait 替换为 UIInterfaceOrientationPortrait

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多