[英]Don't hide input accessoryView when keyboard hides
我希望 inputAccessoryView 在鍵盤關閉時不隱藏。 我嘗試在鍵盤隱藏時更改框架但它不起作用
customView = UIView(frame: CGRect(x: 0, y: 0, width: 10, height: 88))
customView.backgroundColor = UIColor.white
textview.inputAccessoryView = customView
// Tracking the keyboard status
NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardWillBeHidden), name: UIResponder.keyboardWillHideNotification, object: nil)
@objc func keyboardWillHide(sender: NSNotification) {
self.customView.frame = CGRect(x: 0, y: self.view.frame.size.height-88, width: 10, height: 88)
}
您需要將該視圖添加到當前視圖。 通過將其設置為inputAccessoryView
,您基本上是將其添加到第一響應者的視圖中,在這種情況下是鍵盤。
嘗試這個 -
@objc func keyboardWillHide(sender: NSNotification) {
self.customView.frame = CGRect(x: 0, y: self.view.frame.size.height-88, width: 10, height: 88)
self.view.addSubView(self.customView)
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.