gpt4 book ai didi

ios - iOS 有没有办法调整键盘高度?

转载 作者:行者123 更新时间:2023-11-30 11:50:40 28 4
gpt4 key购买 nike

我想更改 iOS 中小数点键盘的高度。我得到默认键盘高度和小数点键盘的黑白高度差。

func resizeKeyboard(note: NSNotification){
let userInfo = note.userInfo!
let duration = userInfo[UIKeyboardAnimationDurationUserInfoKey] as! Double
let curve = userInfo[UIKeyboardAnimationCurveUserInfoKey] as! UInt

var frameEnd = self.view .convert(((userInfo[UIKeyboardFrameEndUserInfoKey] as! NSValue).cgRectValue), from: nil)

if note.name == NSNotification.Name.UIKeyboardWillShow{
Keyboard appears
desiredHeight = 260
}else if note.name == NSNotification.Name.UIKeyboardWillHide{
Keyboard hides
desiredHeight = 260
}

self.heightConstraint.constant = desiredHeight
self.view .setNeedsLayout()

UIView.animate(withDuration: duration, delay: 0, options: UIViewAnimationOptions(rawValue: curve), animations: {
self.view .setNeedsLayout()
}, completion: nil)
}

最佳答案

您无法更改系统键盘的高度,如 documentation说,这并不总是相同的:

You should always use the information in these notifications as opposed to assuming the keyboard is a particular size or in a particular location. The size of the keyboard is not guaranteed to be the same from one input method to another and may also change between different releases of iOS.

这意味着您的代码需要查看 UIKeyboardFrameEndUserInfoKey 来确定实际的键盘高度,并调整/滚动 UI 的其余部分以适应该高度。

关于ios - iOS 有没有办法调整键盘高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48352946/

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