Răsfoiți Sursa

1.修复RA Image在iOS11下键盘监听出错。

Pen Li 8 ani în urmă
părinte
comite
e5a3609129

BIN
RA Image/RA Image.xcodeproj/project.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 2 - 0
RA Image/RA Image.xcodeproj/xcuserdata/macmini1.xcuserdatad/xcschemes/RA Image.xcscheme

@@ -26,6 +26,7 @@
       buildConfiguration = "Debug"
       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      language = ""
       shouldUseLaunchSchemeArgsEnv = "YES">
       <Testables>
       </Testables>
@@ -45,6 +46,7 @@
       buildConfiguration = "Debug"
       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      language = ""
       launchStyle = "0"
       useCustomWorkingDirectory = "NO"
       ignoresPersistentStateOnLaunch = "NO"

+ 16 - 2
RA Image/RA Image/KeyboardListener/JLKeyboardListener.m

@@ -87,10 +87,12 @@
 
 /**在使用过程中切换键盘*/
 - (void)keyboardChangeFrame:(NSNotification *)notification {
+    
+    CGRect begin = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue];
+    CGRect end = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
+    
     // 在屏幕旋转时也会走这个方法,但是此时键盘会 hide -> show -> changeFrame
     if (self.showsKeyboard) {
-        CGRect begin = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue];
-        CGRect end = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
         
         // 在ip6s中使用搜狗输入法和系统键盘切换时发现
         // sougou --> sys : 282 -> 258
@@ -105,9 +107,21 @@
                 [self.delegate keyboardWillChangeHeight:self.keyboardHeight offset:offset withDuration:changeFrameAnimationDuartion];
             }
         }
+    } else {
         
+        // ios11 键盘通知改变。Show Keyboard调用
+        if (end.origin.y < begin.origin.y) {
+            self.showsKeyboard = YES;
+            CGFloat offset = end.size.height - begin.size.height;
+            self.keyboardHeight = end.size.height;
+            if (self.delegate && [self.delegate respondsToSelector:@selector(keyboardWillChangeHeight:offset:withDuration:)]) {
+                [self.delegate keyboardWillChangeHeight:self.keyboardHeight offset:offset withDuration:self.keyboardAnimationDuration];
+            }
+        }
         
     }
+    
+    
 }
 
 #pragma mark - Getter