Browse Source

fix(WKWebview): Reverts #134, fixes issue where keyboard dismiss would scroll to top (#210)

Ryan Linton 5 years ago
parent
commit
9f37ddea61
1 changed files with 0 additions and 35 deletions
  1. 0
    35
      ios/RNCWKWebView.m

+ 0
- 35
ios/RNCWKWebView.m View File

@@ -12,7 +12,6 @@
12 12
 
13 13
 #import "objc/runtime.h"
14 14
 
15
-static NSTimer *keyboardTimer;
16 15
 static NSString *const MessageHanderName = @"ReactNative";
17 16
 
18 17
 // runtime trick to remove WKWebView keyboard default toolbar
@@ -71,19 +70,6 @@ static NSString *const MessageHanderName = @"ReactNative";
71 70
     _automaticallyAdjustContentInsets = YES;
72 71
     _contentInset = UIEdgeInsetsZero;
73 72
   }
74
-
75
-  // Workaround for a keyboard dismissal bug present in iOS 12
76
-  // https://openradar.appspot.com/radar?id=5018321736957952
77
-  if (@available(iOS 12.0, *)) {
78
-    [[NSNotificationCenter defaultCenter]
79
-      addObserver:self
80
-      selector:@selector(keyboardWillHide)
81
-      name:UIKeyboardWillHideNotification object:nil];
82
-    [[NSNotificationCenter defaultCenter]
83
-      addObserver:self
84
-      selector:@selector(keyboardWillShow)
85
-      name:UIKeyboardWillShowNotification object:nil];
86
-  }
87 73
   return self;
88 74
 }
89 75
 
@@ -145,27 +131,6 @@ static NSString *const MessageHanderName = @"ReactNative";
145 131
     [super removeFromSuperview];
146 132
 }
147 133
 
148
--(void)keyboardWillHide
149
-{
150
-    keyboardTimer = [NSTimer scheduledTimerWithTimeInterval:0 target:self selector:@selector(keyboardDisplacementFix) userInfo:nil repeats:false];
151
-    [[NSRunLoop mainRunLoop] addTimer:keyboardTimer forMode:NSRunLoopCommonModes];
152
-}
153
-
154
--(void)keyboardWillShow
155
-{
156
-    if (keyboardTimer != nil) {
157
-        [keyboardTimer invalidate];
158
-    }
159
-}
160
-
161
--(void)keyboardDisplacementFix
162
-{
163
-    // https://stackoverflow.com/a/9637807/824966
164
-    [UIView animateWithDuration:.25 animations:^{
165
-        self.webView.scrollView.contentOffset = CGPointMake(0, 0);
166
-    }];
167
-}
168
-
169 134
 - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context{
170 135
     if ([keyPath isEqual:@"estimatedProgress"] && object == self.webView) {
171 136
         if(_onLoadingProgress){