The problem is that the UISupportedInterfaceOrientations
info key gives you an array of strings. While self.currentOrientation
gives you an enum value from UIDeviceOrientation
. You need a way to map the enum values to the string values. Also note that you are dealing with device orientations and interface orientations.
- (NSString *)deviceOrientationString:(UIDeviceOrientation)orientation {
switch (orientation) (
case UIDeviceOrientationPortrait:
return @"UIInterfaceOrientationPortrait";
case UIDeviceOrientationPortraitUpsideDown:
return @"UIInterfaceOrientationPortraitUpsideDown";
case UIDeviceOrientationLandscapeLeft:
return @"UIInterfaceOrientationLandscapeLeft";
case UIDeviceOrientationLandscapeRight:
return @"UIInterfaceOrientationLandscapeRight";
default:
return @"Invalid Interface Orientation";
}
}
NSString *name = [self deviceOrientationString:self.currentOrientation];
BOOL res = [supportedOrientations containsObject:name];