我希望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)
}发布于 2020-12-30 15:53:50
您需要将该视图添加到当前视图中。通过将其设置为inputAccessoryView,您基本上是将其添加到first responder的视图中,在本例中是一个键盘。
试试这个-
@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)
}https://stackoverflow.com/questions/65503642
复制相似问题