gpt4 book ai didi

swift - 用于 UIPIckerView 的 UITapGestureRecognizer

转载 作者:可可西里 更新时间:2023-10-31 23:59:26 25 4
gpt4 key购买 nike

带有 UIPickerView 的 UITapGestureRecognizer 不工作。为什么?

class someVC: UIViewController, UITapGestureRecognizerDelegate

override func viewDidLoad() {
let tap = UITapGestureRecognizer(target: self, action: "dismissKeyboard")
self.pickerView.addGestureRecognizer(tap)
tap.delegate = self
}

func dismissKeyboard() {
textField.resignFirstResponder()
}

最佳答案

我通过添加覆盖 getureRecognizer 解决了问题

func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}

关于swift - 用于 UIPIckerView 的 UITapGestureRecognizer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26464198/

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