cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmo...@apache.org
Subject git commit: CB-5852: Disable iOS7 keyboard shrinkview, because of layout issues.
Date Tue, 28 Jan 2014 16:38:56 GMT
Updated Branches:
  refs/heads/master 17bdd5fe6 -> 20215013b


CB-5852: Disable iOS7 keyboard shrinkview, because of layout issues.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugins/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugins/commit/20215013
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugins/tree/20215013
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugins/diff/20215013

Branch: refs/heads/master
Commit: 20215013bf91b659b73d5f428ae91dd58be1273a
Parents: 17bdd5f
Author: Michal Mocny <mmocny@gmail.com>
Authored: Wed Jan 22 11:47:22 2014 -0500
Committer: Michal Mocny <mmocny@gmail.com>
Committed: Tue Jan 28 11:38:07 2014 -0500

----------------------------------------------------------------------
 keyboard/src/ios/CDVKeyboard.m | 65 ++++++++++++++++++++-----------------
 1 file changed, 35 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/20215013/keyboard/src/ios/CDVKeyboard.m
----------------------------------------------------------------------
diff --git a/keyboard/src/ios/CDVKeyboard.m b/keyboard/src/ios/CDVKeyboard.m
index c2a6fe9..1887e69 100644
--- a/keyboard/src/ios/CDVKeyboard.m
+++ b/keyboard/src/ios/CDVKeyboard.m
@@ -149,35 +149,39 @@
         return;
     }
 
-    if (ashrinkView) {
-        [nc removeObserver:_shrinkViewKeyboardShowObserver];
-        _shrinkViewKeyboardShowObserver = [nc addObserverForName:UIKeyboardWillShowNotification
-                                                          object:nil
-                                                           queue:[NSOperationQueue mainQueue]
-                                                      usingBlock:^(NSNotification* notification)
{
-                [weakSelf performSelector:@selector(shrinkViewKeyboardWillShow:) withObject:notification
afterDelay:0];
-            }];
-
-        [nc removeObserver:_shrinkViewKeyboardHideObserver];
-        _shrinkViewKeyboardHideObserver = [nc addObserverForName:UIKeyboardWillHideNotification
-                                                          object:nil
-                                                           queue:[NSOperationQueue mainQueue]
-                                                      usingBlock:^(NSNotification* notification)
{
-                [weakSelf performSelector:@selector(shrinkViewKeyboardWillHide:) withObject:notification
afterDelay:0];
-            }];
-    } else {
-        [nc removeObserver:_shrinkViewKeyboardShowObserver];
-        [nc removeObserver:_shrinkViewKeyboardHideObserver];
+    // No-op on iOS7.  It already resizes webview by default, and this plugin is causing
layout issues
+    // with fixed position elements.  We possibly should attempt to implement shringview
= false on iOS7.
+    if (!IsAtLeastiOSVersion(@"7.0")) {
+        if (ashrinkView) {
+            [nc removeObserver:_shrinkViewKeyboardShowObserver];
+            _shrinkViewKeyboardShowObserver = [nc addObserverForName:UIKeyboardWillShowNotification
+                                                              object:nil
+                                                               queue:[NSOperationQueue mainQueue]
+                                                          usingBlock:^(NSNotification* notification)
{
+                    [weakSelf performSelector:@selector(shrinkViewKeyboardWillShow:) withObject:notification
afterDelay:0];
+                }];
 
-        // if a keyboard is already visible (and keyboard was shrunk), hide observer will
NOT be called, so we observe it once
-        if (self.keyboardIsVisible && _shrinkView) {
+            [nc removeObserver:_shrinkViewKeyboardHideObserver];
             _shrinkViewKeyboardHideObserver = [nc addObserverForName:UIKeyboardWillHideNotification
                                                               object:nil
                                                                queue:[NSOperationQueue mainQueue]
                                                           usingBlock:^(NSNotification* notification)
{
-                    [weakSelf shrinkViewKeyboardWillHideHelper:notification];
-                    [[NSNotificationCenter defaultCenter] removeObserver:_shrinkViewKeyboardHideObserver];
+                    [weakSelf performSelector:@selector(shrinkViewKeyboardWillHide:) withObject:notification
afterDelay:0];
                 }];
+        } else {
+            [nc removeObserver:_shrinkViewKeyboardShowObserver];
+            [nc removeObserver:_shrinkViewKeyboardHideObserver];
+
+            // if a keyboard is already visible (and keyboard was shrunk), hide observer
will NOT be called, so we observe it once
+            if (self.keyboardIsVisible && _shrinkView) {
+                _shrinkViewKeyboardHideObserver = [nc addObserverForName:UIKeyboardWillHideNotification
+                                                                  object:nil
+                                                                   queue:[NSOperationQueue
mainQueue]
+                                                              usingBlock:^(NSNotification*
notification) {
+                        [weakSelf shrinkViewKeyboardWillHideHelper:notification];
+                        [[NSNotificationCenter defaultCenter] removeObserver:_shrinkViewKeyboardHideObserver];
+                    }];
+            }
         }
     }
 
@@ -255,6 +259,14 @@
     }
 }
 
+- (void)shrinkViewKeyboardWillHide:(NSNotification*)notif
+{
+    if (!_shrinkView) {
+        return;
+    }
+    [self shrinkViewKeyboardWillHideHelper:notif];
+}
+
 - (void)shrinkViewKeyboardWillHideHelper:(NSNotification*)notif
 {
     self.webView.scrollView.scrollEnabled = YES;
@@ -267,13 +279,6 @@
     self.webView.frame = newFrame;
 }
 
-- (void)shrinkViewKeyboardWillHide:(NSNotification*)notif
-{
-    if (_shrinkView) {
-        [self shrinkViewKeyboardWillHideHelper:notif];
-    }
-}
-
 // //////////////////////////////////////////////////
 
 - (void)dealloc


Mime
View raw message