1

在这一行:[self deviceInterfaceOrientationChanged:interfaceOrientation];

我收到此警告

Implicit conversion from enumeration type ' UIInterfaceOrientation' to different enumeration type 'UIDeviceOrientation'?

你能帮我吗?拜托。感谢你

这是代码:

     -(void) receivedRotate: (NSNotification*) 通知
{
    NSLog(@"receivedRotate");
    UIDeviceOrientation interfaceOrientation = [[UIDevice currentDevice] 方向];

    如果(接口方向!= UIDeviceOrientationUnknown){
        [self deviceInterfaceOrientationChanged:interfaceOrientation];


    } 别的 {
        NSLog(@"未知设备方向");
    }
}
4

1 回答 1

0

UIDeviceOrientation 和 UIInterfaceOrientation 是不同的类型,第一个是设备方向,包括其他状态,例如 Face up 或 Face Down 等,而第二个仅涵盖 2D 状态,例如 Portrait 和 Landscape。

不要从设备获取设备方向,而是从状态栏获取,如下所示:

[[UIApplication sharedApplication] statusBarOrientation] 

此方法将返回一个 UIInterfaceOrientation 值,问题就会消失。

于 2014-11-18T20:02:56.027 回答