You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2019/01/06 11:58:34 UTC

[GitHub] cvanem commented on issue #417: Keyboard Dismissal Leaves Viewport Shifted in iOS 12 / XCode 10

cvanem commented on issue #417: Keyboard Dismissal Leaves Viewport Shifted in iOS 12 / XCode 10
URL: https://github.com/apache/cordova-ios/issues/417#issuecomment-451736105
 
 
   For anyone using cordova [inappbrowser](https://github.com/apache/cordova-plugin-inappbrowser), here is a slightly modified fix of mlynch's post above that works nicely for inappbrowser:
   
   Make the following changes to file: **CDVWKInAppBrowser.m**
   
   **1. Add this directly before the pluginInitialize function:**
       
       NSTimer *timer;
   
   **2. Add this to the bottom of the pluginInitialize function:**
   
        [[NSNotificationCenter defaultCenter]
        addObserver:self
        selector:@selector(keyboardWillHide)
        name:UIKeyboardWillHideNotification object:nil];
   
       [[NSNotificationCenter defaultCenter]
        addObserver:self
        selector:@selector(keyboardWillShow)
        name:UIKeyboardWillShowNotification object:nil];   
   
   **3. Add these directly below the pluginInitialize function:**
   
   ```
    -(void)keyboardWillHide
   {       
       if (@available(iOS 12.0, *)) {
           timer = [NSTimer scheduledTimerWithTimeInterval:0 target:self selector:@selector(keyboardDisplacementFix) userInfo:nil repeats:false];
           [[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
       }
   }
   
    -(void)keyboardWillShow
   {    
       if (timer != nil) {
           [timer invalidate];
       }
   }
   
    -(void)keyboardDisplacementFix
   {    
       if ([self.inAppBrowserViewController.webView respondsToSelector:@selector(scrollView)]) { 
           [UIView animateWithDuration:.25 animations:^{
               ((UIScrollView*)[self.inAppBrowserViewController.webView scrollView]).contentOffset = CGPointMake(0, 0);
           }];        
       } 
    }
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

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