diff --git a/src/ios/YoikScreenOrientation.h b/src/ios/YoikScreenOrientation.h index dd23599..f2d4c67 100644 --- a/src/ios/YoikScreenOrientation.h +++ b/src/ios/YoikScreenOrientation.h @@ -25,6 +25,7 @@ @interface YoikScreenOrientation : CDVPlugin - (void)screenOrientation:(CDVInvokedUrlCommand *)command; +@property (strong, nonatomic) NSArray *originalSupportedOrientations; @end diff --git a/src/ios/YoikScreenOrientation.m b/src/ios/YoikScreenOrientation.m index 9ffe8fa..3008b0c 100644 --- a/src/ios/YoikScreenOrientation.m +++ b/src/ios/YoikScreenOrientation.m @@ -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