cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject [45/50] cordova-plugin-screen-orientation git commit: make iOS rotate as needed when lockOrientation is called
Date Mon, 23 May 2016 13:42:43 GMT
make iOS rotate as needed when lockOrientation is called


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/commit/ec3e90db
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/tree/ec3e90db
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/diff/ec3e90db

Branch: refs/heads/master
Commit: ec3e90dbc84f5ade4a3644517aae8af7dbae1f0e
Parents: ff0d1fb
Author: Tony Homer <tony.homer@intel.com>
Authored: Fri Apr 22 10:55:44 2016 -0400
Committer: Tony Homer <tony.homer@intel.com>
Committed: Mon May 16 15:30:58 2016 -0400

----------------------------------------------------------------------
 ...ViewController+UpdateSupportedOrientations.h | 31 +++++++++++++++++
 ...ViewController+UpdateSupportedOrientations.m | 35 ++++++++++++++++++++
 src/ios/YoikScreenOrientation.h                 |  1 +
 src/ios/YoikScreenOrientation.m                 | 27 ++++++++++-----
 4 files changed, 85 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/blob/ec3e90db/src/ios/CDVViewController+UpdateSupportedOrientations.h
----------------------------------------------------------------------
diff --git a/src/ios/CDVViewController+UpdateSupportedOrientations.h b/src/ios/CDVViewController+UpdateSupportedOrientations.h
new file mode 100644
index 0000000..cdd4073
--- /dev/null
+++ b/src/ios/CDVViewController+UpdateSupportedOrientations.h
@@ -0,0 +1,31 @@
+/*
+ The MIT License (MIT)
+ 
+ Copyright (c) 2014
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+ */
+
+#import <Cordova/CDVViewController.h>
+
+@interface CDVViewController (UpdateSupportedOrientations)
+
+- (void)updateSupportedOrientations:(NSArray *)orientations;
+
+@end

http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/blob/ec3e90db/src/ios/CDVViewController+UpdateSupportedOrientations.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVViewController+UpdateSupportedOrientations.m b/src/ios/CDVViewController+UpdateSupportedOrientations.m
new file mode 100644
index 0000000..03421b7
--- /dev/null
+++ b/src/ios/CDVViewController+UpdateSupportedOrientations.m
@@ -0,0 +1,35 @@
+/*
+ The MIT License (MIT)
+ 
+ Copyright (c) 2014
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+ */
+
+#import "CDVViewController+UpdateSupportedOrientations.h"
+
+@implementation CDVViewController (UpdateSupportedOrientations)
+
+- (void)updateSupportedOrientations:(NSArray *)orientations {
+	
+	[self setValue:orientations forKey:@"supportedOrientations"];
+
+}
+
+@end

http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/blob/ec3e90db/src/ios/YoikScreenOrientation.h
----------------------------------------------------------------------
diff --git a/src/ios/YoikScreenOrientation.h b/src/ios/YoikScreenOrientation.h
index a90b9c6..dd23599 100644
--- a/src/ios/YoikScreenOrientation.h
+++ b/src/ios/YoikScreenOrientation.h
@@ -20,6 +20,7 @@
 */
 
 #import <Cordova/CDVPlugin.h>
+#import <Cordova/CDVViewController.h>
 
 @interface YoikScreenOrientation : CDVPlugin
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/blob/ec3e90db/src/ios/YoikScreenOrientation.m
----------------------------------------------------------------------
diff --git a/src/ios/YoikScreenOrientation.m b/src/ios/YoikScreenOrientation.m
index e87367c..9ffe8fa 100644
--- a/src/ios/YoikScreenOrientation.m
+++ b/src/ios/YoikScreenOrientation.m
@@ -20,6 +20,7 @@
 */
 
 #import "YoikScreenOrientation.h"
+#import "CDVViewController+UpdateSupportedOrientations.h"
 
 @implementation YoikScreenOrientation
 
@@ -61,9 +62,8 @@
         [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
 
         // SEE https://github.com/Adlotto/cordova-plugin-recheck-screen-orientation
-        // HACK: Force rotate by changing the view hierarchy. Present modal view then dismiss
it immediately
-        // This has been changed substantially since iOS8 broke it...
-        ForcedViewController *vc = [[ForcedViewController alloc] init];
+        // HACK: Force rotate by changing the view hierarchy.
+		ForcedViewController *vc = [[ForcedViewController alloc] init];
         vc.calledWith = orientationIn;
 
         // backgound should be transparent as it is briefly visible
@@ -78,12 +78,7 @@
 #endif
 
         dispatch_async(dispatch_get_main_queue(), ^{
-            [self.viewController presentViewController:vc animated:NO completion:^{
-                // added to support iOS8 beta 5, @see issue #19
-                dispatch_after(0, dispatch_get_main_queue(), ^{
-                    [self.viewController dismissViewControllerAnimated:NO completion:nil];
-                });
-            }];
+            [self.viewController presentViewController:vc animated:NO completion:nil];
         });
 
     }];
@@ -93,6 +88,20 @@
 
 @implementation ForcedViewController
 
+-(void) viewDidAppear:(BOOL)animated {
+	CDVViewController *presenter = (CDVViewController*)self.presentingViewController;
+	
+	if ([self.calledWith rangeOfString:@"portrait"].location != NSNotFound) {
+		[presenter updateSupportedOrientations:@[[NSNumber numberWithInt:UIInterfaceOrientationPortrait]]];
+
+	} else if([self.calledWith rangeOfString:@"landscape"].location != NSNotFound) {
+		[presenter updateSupportedOrientations:@[[NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft],
[NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight]]];
+	} else {
+		[presenter updateSupportedOrientations:@[[NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft],
[NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight], [NSNumber numberWithInt:UIInterfaceOrientationPortrait]]];
+	}
+	[presenter dismissViewControllerAnimated:NO completion:nil];
+}
+
 - (UIInterfaceOrientationMask) supportedInterfaceOrientations
 {
     if ([self.calledWith rangeOfString:@"portrait"].location != NSNotFound) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message