gpt4 book ai didi

swift - 我将如何在 inputAccessoryView 中的 uiview 上方垂直添加 uiview?

转载 作者:行者123 更新时间:2023-11-30 13:12:15 24 4
gpt4 key购买 nike

我正在尝试在当前输入附件 View 上方添加一个包含多个按钮的 uiview。我当前的输入附件 View 是一个不断增长的文本字段(如 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
}
}

Example of what I'm trying to do, the app (Facebook Messenger) has a growing textfield or textinput, and in this case, an bar of buttons bellow.

My current view, as mentioned earlier.

最佳答案

try this code

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
}


}

关于swift - 我将如何在 inputAccessoryView 中的 uiview 上方垂直添加 uiview?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38607766/

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