mirror of
https://github.com/apache/cordova-plugin-screen-orientation.git
synced 2026-04-23 00:00:14 +08:00
support interoperability between Orientation preference and screen-orientation plugin
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
@interface YoikScreenOrientation : CDVPlugin
|
||||
|
||||
- (void)screenOrientation:(CDVInvokedUrlCommand *)command;
|
||||
@property (strong, nonatomic) NSArray *originalSupportedOrientations;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -28,9 +28,19 @@
|
||||
{
|
||||
[self.commandDelegate runInBackground:^{
|
||||
|
||||
if(self.originalSupportedOrientations == nil) {
|
||||
self.originalSupportedOrientations = [self.viewController valueForKey:@"supportedOrientations"];
|
||||
}
|
||||
|
||||
NSArray* arguments = command.arguments;
|
||||
NSString* orientationIn = [arguments objectAtIndex:1];
|
||||
|
||||
if ([orientationIn isEqual: @"unlocked"]) {
|
||||
[(CDVViewController*)self.viewController updateSupportedOrientations:self.originalSupportedOrientations];
|
||||
self.originalSupportedOrientations = nil;
|
||||
return;
|
||||
}
|
||||
|
||||
// grab the device orientation so we can pass it back to the js side.
|
||||
NSString *orientation;
|
||||
switch ([[UIDevice currentDevice] orientation]) {
|
||||
@@ -51,10 +61,6 @@
|
||||
break;
|
||||
}
|
||||
|
||||
if ([orientationIn isEqual: @"unlocked"]) {
|
||||
orientationIn = orientation;
|
||||
}
|
||||
|
||||
// we send the result prior to the view controller presentation so that the JS side
|
||||
// is ready for the unlock call.
|
||||
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
||||
|
||||
Reference in New Issue
Block a user