[
https://issues.apache.org/jira/browse/CB-13405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16288040#comment-16288040
]
ASF GitHub Bot commented on CB-13405:
-------------------------------------
maverickmishra closed pull request #24: CB-13405: (ios) Go to last used
orientation before locking when unlocking screen on iOS
URL: https://github.com/apache/cordova-plugin-screen-orientation/pull/24
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/src/ios/CDVOrientation.h b/src/ios/CDVOrientation.h
index 48166a3..6bdd4d4 100644
--- a/src/ios/CDVOrientation.h
+++ b/src/ios/CDVOrientation.h
@@ -24,7 +24,11 @@
#import <Cordova/CDVViewController.h>
@interface CDVOrientation : CDVPlugin
-{}
+{
+@protected
+ BOOL _isLocked;
+ UIInterfaceOrientation _lastOrientation;
+}
- (void)screenOrientation:(CDVInvokedUrlCommand *)command;
diff --git a/src/ios/CDVOrientation.m b/src/ios/CDVOrientation.m
index c7704e4..0152680 100644
--- a/src/ios/CDVOrientation.m
+++ b/src/ios/CDVOrientation.m
@@ -51,21 +51,37 @@ -(void)screenOrientation:(CDVInvokedUrlCommand *)command
SEL selector = NSSelectorFromString(@"setSupportedOrientations:");
if([vc respondsToSelector:selector]) {
- ((void (*)(CDVViewController*, SEL,
NSMutableArray*))objc_msgSend)(vc,selector,result);
+ if (orientationMask != 15 || [UIDevice currentDevice] == nil) {
+ ((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 (orientationMask != 15) {
+ if (!_isLocked) {
+ _lastOrientation = [UIApplication
sharedApplication].statusBarOrientation;
+ }
+ 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];
+ }
+ } else {
+ if (_lastOrientation != UIInterfaceOrientationUnknown) {
+ [[UIDevice currentDevice] setValue:[NSNumber
numberWithInt:_lastOrientation] forKey:@"orientation"];
+ ((void (*)(CDVViewController*, SEL,
NSMutableArray*))objc_msgSend)(vc,selector,result);
+ [UINavigationController
attemptRotationToDeviceOrientation];
+ }
}
if (value != nil) {
+ _isLocked = true;
[[UIDevice currentDevice] setValue:value
forKey:@"orientation"];
+ } else {
+ _isLocked = false;
}
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> iOS screen orientation plugin fails to reset on unlock
> ------------------------------------------------------
>
> Key: CB-13405
> URL: https://issues.apache.org/jira/browse/CB-13405
> Project: Apache Cordova
> Issue Type: Bug
> Components: cordova-plugin-screen-orientation
> Environment: all iOS
> Reporter: Dan Field
> Assignee: Vishal Mishra
> Priority: Minor
> Labels: Triaged, iOS, in-progress
> Original Estimate: 6h
> Remaining Estimate: 6h
>
> When locking and then unlocking the screen orientation on iOS, the device
> fails to rotate until user manually rotates back and forth.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]