Implicit conversion from enumeration type 'UIInterfaceOrientation' to different enumeration type 'UIDeviceOrientation'
-
29-10-2019 - |
Question
I am getting the above compiler warning for the code below. I understand the difference between Interface and Device orientation, but am unsure how to amend to remove the warning. Can anyone help ?
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (ViewController != NULL) {
[ViewController configureForDeviceOrientation:toInterfaceOrientation];
}
if (Controller != NULL) {
[Controller configureForDeviceOrientation:toInterfaceOrientation];
}
currentOrientation = toInterfaceOrientation;
}
Solution
just cast it [Controller configureForDeviceOrientation:(UIDeviceOrientation)toInterfaceOrientation];
OTHER TIPS
Your method configureForDeviceOrientation:
is expecting to be passed a UIDeviceOrientation
enum and not a UIInterfaceOrientation
which you are passing in.
If you correct your method to accept a UIInterfaceOrientation
from the willRotateToInterfaceOrientation:
method, then you'll resolve the issue.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow