Resume Orientaion on iOS

NSArray *supportedOrientations = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UISupportedInterfaceOrientations"];
for (NSString *orientation in supportedOrientations) {
    if ([orientation isEqualToString:@"UIInterfaceOrientationPortrait"] ||
        [orientation isEqualToString:@"UIInterfaceOrientationPortraitUpsideDown"]) {
        NSLog(@"Portrait mode!");
        NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
        [[UIDevice currentDevice] setValue:value forKey:@"orientation"];
    } else if ([orientation isEqualToString:@"UIInterfaceOrientationLandscapeLeft"] ||
               [orientation isEqualToString:@"UIInterfaceOrientationLandscapeRight"]) {
        NSLog(@"Landscape mode!");
        NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
        [[UIDevice currentDevice] setValue:value forKey:@"orientation"];
    }
}