gpt4 book ai didi

swift - 以编程方式为 UITextField 创建 .touchUpInside 事件

转载 作者:行者123 更新时间:2023-11-28 06:11:34 25 4
gpt4 key购买 nike

使用 UITextField 添加了一个 pickerView。

我正在尝试以编程方式触发 pickerView。

    func myTypeDetector (textfield: UITextField) {
typeLabel.delegate = self
self.setType(textField: typeLabel)
}

override func viewDidLoad() {
super.viewDidLoad()
typeLabel.addTarget(self, action: #selector(NewSpeciesVC.myTypeDetector(textfield:)), for: UIControlEvents.touchUpInside)
}

我已经找到了如何通过 UIButton 做到这一点

self.typeLabel.sendActions(for: .touchUpInside)

但是,这不适用于 UITextField。

我想以编程方式使用 TextField 创建事件,或使用 UIButton 创建 PickerView 事件。

有什么建议吗?

最佳答案

我需要做同样的事情并想通了:

self.typelabel.becomeFirstResponder()

关于swift - 以编程方式为 UITextField 创建 .touchUpInside 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46375700/

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