我尝试在我当前的输入附件视图上方添加包含多个按钮的uiview。我当前的输入附件视图是一个不断增长的textField(如iOS标准文本消息应用程序)。
class ViewController: UIViewController {
let textInputBar = ALTextInputBar()
// The magic sauce
// This is how we attach the input bar to the keyboard
override var inputAccessoryView: UIView? {
get {
return textInputBar
}
}
// Another ingredient in the magic sauce
override func canBecomeFirstResponder() -> Bool {
return true
}
}
答案 0 :(得分:0)
试试这段代码
class ViewController: UIViewController {
@IBOutlet weak var myTextField: UITextField!
var textInputBar:UIView = ALTextInputBar()// if it is a uiview type
override func viewDidLoad() {
super.viewDidLoad()
myTextField.inputAccessoryView = textInputBar
}
}