support interoperability between Orientation preference and screen-orientation plugin

This commit is contained in:
Tony Homer
2016-05-16 14:24:44 -04:00
parent a661578b4c
commit 937577842b
2 changed files with 11 additions and 4 deletions
+1
View File
@@ -25,6 +25,7 @@
@interface YoikScreenOrientation : CDVPlugin
- (void)screenOrientation:(CDVInvokedUrlCommand *)command;
@property (strong, nonatomic) NSArray *originalSupportedOrientations;
@end
+10 -4
View File
@@ -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