Ben*_*Ben 5 objective-c ipad ios react-native react-native-ios
我们遇到了一个特定的错误iOS/iPadOS,当 iPad 在屏幕上显示浮动(类似 iPhone)键盘(而不是固定键盘)时,该错误似乎会被触发。
我们的问题特定于 React Native 和KeyboardAvoidingView组件。当组件渲染并且键盘浮动时,KeyboardAvoidingView完全错误地计算了键盘所需的高度,并隐藏了大约 95% 的屏幕高度。
本身KeyboardAvoidingView似乎没有办法检测浮动键盘是否打开。
是否有一个特定的 API 可以用来检测此键盘模式,以便我们可以关闭它KeyboardAvoidingView?
键盘事件(keyboardWillShow、keyboardDidShow等)似乎没有返回任何具体线索。
没有这样的模式枚举/指示器(至少目前如此),但有键盘框架信息
Run Code Online (Sandbox Code Playgroud)public class let keyboardFrameBeginUserInfoKey: String // NSValue of CGRect public class let keyboardFrameEndUserInfoKey: String // NSValue of CGRect
在相应的键盘通知中
Run Code Online (Sandbox Code Playgroud)public class let keyboardWillShowNotification: NSNotification.Name public class let keyboardDidShowNotification: NSNotification.Name public class let keyboardWillHideNotification: NSNotification.Name public class let keyboardDidHideNotification: NSNotification.Name public class let keyboardWillChangeFrameNotification: NSNotification.Name public class let keyboardDidChangeFrameNotification: NSNotification.Name
相对于屏幕边界
UIScreen.main.bounds
Run Code Online (Sandbox Code Playgroud)
可以检测键盘边框是否在屏幕底部边缘或浮动。
概括地说,它就像
keyboardAttached = NSMaxX(screenBounds) == NSMaxX(keyboardFrame) &&
NSMaxY(screenBounds) == NSMaxY(keyboardFrame) &&
NSWidth(screenBounds) == NSWidth(keyboardFrame)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1583 次 |
| 最近记录: |