gpt4 book ai didi

Swift textFieldDidChangeSelection 在 ios 12 中没有被调用

转载 作者:行者123 更新时间:2023-12-05 02:01:35 24 4
gpt4 key购买 nike

所以我制作了这个功能,当 2 个文本字段达到最小文本数量时触发该功能将使按钮启用。

它适用于 ios 13 及更高版本,但不适用于 ios 12....我不知道它如何以及为什么不起作用

所以基本上我的 textFieldDidChangeSelection 在我的文本字段上输入时不会触发任何东西......它在 ios 12 上不起作用,但它在 13 及以上版本上工作

我尝试在 textFieldDidChangeSelection 上打印一些内容,但控制台上什么也没有打印

这是我的代码

//这是我的函数代码

func buttonReady() {
if phoneNumberTextField.text!.count > 8 && textPinTextField.text!.count == 6{
loginButton.isUserInteractionEnabled = true
loginButton.backgroundColor = UIColor.init(string: COLOR_RED)
loginButton.setTitleColor(UIColor.white, for: .normal)
print("ahaaaa 🏌🏻")
} else {
loginButton.isUserInteractionEnabled = false
loginButton.backgroundColor = UIColor.init(string: COLOR_GREY_BUTTON)
loginButton.setTitleColor(UIColor.init(string: COLOR_GREY_TEXT), for: .normal)
print("hmmmm 🤔")
}
}

我在这里使用那个函数

func textFieldDidChangeSelection(_ textField: UITextField) {
if textField == phoneNumberTextField {
buttonReady()

}
if textField == textPinTextField {
buttonReady()

}

}

这里

override func viewDidLoad() {
super.viewDidLoad()

// Do any additional setup after loading the view.

buttonReady()
hideKeyboardWhenTappedAround()
}

我在自定义文本字段中使用 SkyFloatingLabelTextFIeld

我仍然不明白为什么该功能在 ios12 和 ios 13 及更高版本上工作时却无法在 ios12 上工作

最佳答案

同样的问题

你可以试试这个

    override func viewDidLoad() {
super.viewDidLoad()

// Do any additional setup after loading the view.
phoneNumberTextField.addTarget(self, action: #selector(textFieldDidChange), for: .editingChanged)
textPinTextField.addTarget(self, action: #selector(textFieldDidChange), for: .editingChanged)
buttonReady()
hideKeyboardWhenTappedAround()
}

    @objc func textFieldDidChange() {
buttonReady()
}

关于Swift textFieldDidChangeSelection 在 ios 12 中没有被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66419691/

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