You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2014/04/25 20:14:24 UTC
[03/10] git commit: CB-5649 - InAppBrowser overrides App's orientation
CB-5649 - InAppBrowser overrides App's orientation
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/commit/b9f8fcd8
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/b9f8fcd8
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/b9f8fcd8
Branch: refs/heads/master
Commit: b9f8fcd8a93f802dcf85f620f70a6dcd23b0f9c7
Parents: 11f833b
Author: Shazron Abdullah <sh...@apache.org>
Authored: Thu Apr 17 16:32:34 2014 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Thu Apr 17 16:32:40 2014 -0700
----------------------------------------------------------------------
src/ios/CDVInAppBrowser.h | 8 +++++++-
src/ios/CDVInAppBrowser.m | 36 +++++++++++++++++++++++++++++++++++-
2 files changed, 42 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/b9f8fcd8/src/ios/CDVInAppBrowser.h
----------------------------------------------------------------------
diff --git a/src/ios/CDVInAppBrowser.h b/src/ios/CDVInAppBrowser.h
index e643962..0ba07f1 100644
--- a/src/ios/CDVInAppBrowser.h
+++ b/src/ios/CDVInAppBrowser.h
@@ -63,7 +63,7 @@
@end
-@interface CDVInAppBrowserViewController : UIViewController <UIWebViewDelegate>{
+@interface CDVInAppBrowserViewController : UIViewController <UIWebViewDelegate, CDVScreenOrientationDelegate>{
@private
NSString* _userAgent;
NSString* _prevUserAgent;
@@ -92,4 +92,10 @@
- (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent browserOptions: (CDVInAppBrowserOptions*) browserOptions;
+@end
+
+@interface CDVInAppBrowserNavigationController : UINavigationController
+
+@property (nonatomic, weak) id <CDVScreenOrientationDelegate> orientationDelegate;
+
@end
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/b9f8fcd8/src/ios/CDVInAppBrowser.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVInAppBrowser.m b/src/ios/CDVInAppBrowser.m
index 68675c5..aed735c 100644
--- a/src/ios/CDVInAppBrowser.m
+++ b/src/ios/CDVInAppBrowser.m
@@ -216,8 +216,9 @@
_previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
- UINavigationController* nav = [[UINavigationController alloc]
+ CDVInAppBrowserNavigationController* nav = [[CDVInAppBrowserNavigationController alloc]
initWithRootViewController:self.inAppBrowserViewController];
+ nav.orientationDelegate = self.inAppBrowserViewController;
nav.navigationBarHidden = YES;
// Run later to avoid the "took a long time" log message.
dispatch_async(dispatch_get_main_queue(), ^{
@@ -965,3 +966,36 @@
}
@end
+
+@implementation CDVInAppBrowserNavigationController : UINavigationController
+
+#pragma mark CDVScreenOrientationDelegate
+
+- (BOOL)shouldAutorotate
+{
+ if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(shouldAutorotate)]) {
+ return [self.orientationDelegate shouldAutorotate];
+ }
+ return YES;
+}
+
+- (NSUInteger)supportedInterfaceOrientations
+{
+ if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(supportedInterfaceOrientations)]) {
+ return [self.orientationDelegate supportedInterfaceOrientations];
+ }
+
+ return 1 << UIInterfaceOrientationPortrait;
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+ if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(shouldAutorotateToInterfaceOrientation:)]) {
+ return [self.orientationDelegate shouldAutorotateToInterfaceOrientation:interfaceOrientation];
+ }
+
+ return YES;
+}
+
+
+@end