Rotate to specified orientation when locked

Refactor
This commit is contained in:
Pascal Häusler
2017-03-03 15:03:09 +01:00
committed by Jesse MacFadyen
parent f0c65cfee1
commit fce44f4942
3 changed files with 28 additions and 12 deletions
+19 -2
View File
@@ -52,14 +52,31 @@
if([vc respondsToSelector:selector]) {
((void (*)(CDVViewController*, SEL, NSMutableArray*))objc_msgSend)(vc,selector,result);
if ([UIDevice currentDevice] != nil){
NSNumber *value = nil;
if(orientationMask == 8 || orientationMask == 12) {
value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
} else if (orientationMask == 4){
value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft];
} else if (orientationMask == 1 || orientationMask == 3) {
value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
} else if (orientationMask == 2) {
value = [NSNumber numberWithInt:UIInterfaceOrientationPortraitUpsideDown];
}
if (value != nil) {
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
}
}
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
}
else {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_INVALID_ACTION messageAsString:@"Error calling to set supported orientations"];
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_INVALID_ACTION messageAsString:@"Error calling to set supported orientations"];
}
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
@end
@end
+1 -1
View File
@@ -57,6 +57,6 @@ module.exports = {
}
}
}
};
require("cordova/exec/proxy").add("CDVOrientation", module.exports);