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

时间:2011-12-07 10:22:04

标签: iphone objective-c xcode sdk uideviceorientation

我收到以下代码的上述编译器警告。我理解接口和设备方向之间的区别,但不确定如何修改以删除警告。有人可以帮忙吗?

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (ViewController != NULL) {
    [ViewController configureForDeviceOrientation:toInterfaceOrientation];
}
if (Controller != NULL) {
    [Controller configureForDeviceOrientation:toInterfaceOrientation];
}
currentOrientation = toInterfaceOrientation;
}

2 个答案:

答案 0 :(得分:6)

只需投出[Controller configureForDeviceOrientation:(UIDeviceOrientation)toInterfaceOrientation];

答案 1 :(得分:2)

您的方法configureForDeviceOrientation:期望传递UIDeviceOrientation枚举,而不是您传递的UIInterfaceOrientation

如果您更正方法以接受UIInterfaceOrientation方法中的willRotateToInterfaceOrientation:,那么您将解决此问题。

相关问题