mirror of
https://github.com/apache/cordova-plugin-screen-orientation.git
synced 2026-04-23 00:00:14 +08:00
Rotate to specified orientation when locked
Refactor
This commit is contained in:
committed by
Jesse MacFadyen
parent
f0c65cfee1
commit
fce44f4942
@@ -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
|
||||
|
||||
@@ -57,6 +57,6 @@ module.exports = {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
require("cordova/exec/proxy").add("CDVOrientation", module.exports);
|
||||
|
||||
Reference in New Issue
Block a user