mirror of
https://github.com/apache/cordova-plugin-screen-orientation.git
synced 2025-05-05 01:32:59 +08:00
CB-13405: (ios) undo lock when resetting
This commit is contained in:
parent
114aeef0bb
commit
b4db5e2796
@ -26,6 +26,7 @@
|
|||||||
@interface CDVOrientation : CDVPlugin
|
@interface CDVOrientation : CDVPlugin
|
||||||
{
|
{
|
||||||
@protected
|
@protected
|
||||||
|
BOOL _isLocked;
|
||||||
UIInterfaceOrientation _lastOrientation;
|
UIInterfaceOrientation _lastOrientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,12 +51,16 @@
|
|||||||
SEL selector = NSSelectorFromString(@"setSupportedOrientations:");
|
SEL selector = NSSelectorFromString(@"setSupportedOrientations:");
|
||||||
|
|
||||||
if([vc respondsToSelector:selector]) {
|
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){
|
if ([UIDevice currentDevice] != nil){
|
||||||
NSNumber *value = nil;
|
NSNumber *value = nil;
|
||||||
if (orientationMask != 15) {
|
if (orientationMask != 15) {
|
||||||
_lastOrientation = [UIApplication sharedApplication].statusBarOrientation;
|
if (!_isLocked) {
|
||||||
|
_lastOrientation = [UIApplication sharedApplication].statusBarOrientation;
|
||||||
|
}
|
||||||
if(orientationMask == 8 || orientationMask == 12) {
|
if(orientationMask == 8 || orientationMask == 12) {
|
||||||
value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
|
value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
|
||||||
} else if (orientationMask == 4){
|
} else if (orientationMask == 4){
|
||||||
@ -67,13 +71,17 @@
|
|||||||
value = [NSNumber numberWithInt:UIInterfaceOrientationPortraitUpsideDown];
|
value = [NSNumber numberWithInt:UIInterfaceOrientationPortraitUpsideDown];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (_lastOrientation != nil) {
|
if (_lastOrientation != UIInterfaceOrientationUnknown) {
|
||||||
value = [NSNumber numberWithInt:_lastOrientation];
|
[[UIDevice currentDevice] setValue:[NSNumber numberWithInt:_lastOrientation] forKey:@"orientation"];
|
||||||
|
((void (*)(CDVViewController*, SEL, NSMutableArray*))objc_msgSend)(vc,selector,result);
|
||||||
|
[UINavigationController attemptRotationToDeviceOrientation];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (value != nil) {
|
if (value != nil) {
|
||||||
|
_isLocked = true;
|
||||||
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
|
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
|
||||||
[UINavigationController attemptRotationToDeviceOrientation];
|
} else {
|
||||||
|
_isLocked = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user