gpt4 book ai didi

iphone - 根据键盘和预测 TextView iOS 8 向上或向下移动我的工具栏

转载 作者:行者123 更新时间:2023-12-03 18:48:17 27 4
gpt4 key购买 nike

我正在开发一个聊天应用程序,它在聊天屏幕的底部有一个工具栏(带有 UITextView 和其他按钮),与 Whatsapp 相同,它根据键盘可见性上下移动,这是有效的iOS 7 之前都可以。

我使用了UIKeyboardDidChangeFrameNotification,基于此我使用下面的代码来获取键盘框架

  CGRect kKeyBoardFrame = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];

并相应地设置工具栏的框架。

但它无法在 iOS 8 上使用预测文本。任何帮助表示赞赏。

编辑:

UIKeyboardDidChangeFrameNotification 当预测 TextView 向上或向下移动时不会被触发。

附加快照

Image with predictive text enter image description here

最佳答案

iOS 10、9 一直降到 5

UIKeyboardDidChangeFrameNotification

Posted immediately after a change in the keyboard’s frame.

The notification object is nil. The userInfo dictionary contains information about the keyboard. Use the keys described in Keyboard Notification User Info Keys to get the location and size of the keyboard from the userInfo dictionary.

在 iPhone 6、iOS 10、9、8.4 上进行测试(链接、构建、运行,请参阅下面的日志)。

NSNotification 字典显示 UIKeyboardFrameBeginUserInfoKeyUIKeyboardFrameEndUserInfoKeyCGRect 值的反转,以及所有 4 个 UIKeyboard__Notification 在预测附件 View 更改时触发。

swift 3

func addObserver(forName: Notification.Name) {
NotificationCenter.default.addObserver(forName: forName,
object: nil,
queue: OperationQueue.main)
{ (note:Notification!) -> Void in
print("\(forName): \(note)")
}
}

addObserver(forName: .UIKeyboardWillShow)
addObserver(forName: .UIKeyboardDidShow)
addObserver(forName: .UIKeyboardWillChangeFrame)
addObserver(forName: .UIKeyboardDidChangeFrame)

开启预测

enter image description here

日志:

UIKeyboardWillChangeFrameNotification:
UIKeyboardWillShowNotification:
UIKeyboardDidChangeFrameNotification:
UIKeyboardDidShowNotification:
userInfo = { UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {375, 258}}"; UIKeyboardCenterBeginUserInfoKey = "NSPoint: {187.5, 554.5}"; UIKeyboardCenterEndUserInfoKey = "NSPoint: {187.5, 538}"; UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 442}, {375, 225}}"; UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 409}, {375, 258}}"; }

关闭预测

enter image description here

日志:

UIKeyboardWillChangeFrameNotification:
UIKeyboardWillShowNotification:
UIKeyboardDidChangeFrameNotification:
UIKeyboardDidShowNotification:
userInfo = { UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {375, 225}}"; UIKeyboardCenterBeginUserInfoKey = "NSPoint: {187.5, 538}"; UIKeyboardCenterEndUserInfoKey = "NSPoint: {187.5, 554.5}"; UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 409}, {375, 258}}"; UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 442}, {375, 225}}"; }

<小时/>

► 在 GitHub 上找到此解决方案以及关于 Swift Recipes 的更多详细信息.

关于iphone - 根据键盘和预测 TextView iOS 8 向上或向下移动我的工具栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25946121/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com