gpt4 book ai didi

ios - 使用 Swift 实现 UITextFieldDelegate

转载 作者:IT王子 更新时间:2023-10-29 05:12:41 25 4
gpt4 key购买 nike

我的 ViewController 类实现了 UITextFieldDelegate。我没有自动完成诸如 textFieldShouldBeginEditing 之类的功能。这是 XCode 6 中的错误吗?这是我的类实现。

class ViewController: UIViewController, UITextFieldDelegate

最佳答案

class ViewController: UIViewController,UITextFieldDelegate  //set delegate to class 

@IBOutlet var txtValue: UITextField //create a textfile variable

override func viewDidLoad() {
super.viewDidLoad()
txtValue.delegate = self //set delegate to textfile
}


func textFieldDidBeginEditing(textField: UITextField!) { //delegate method

}

func textFieldShouldEndEditing(textField: UITextField!) -> Bool { //delegate method
return false
}

func textFieldShouldReturn(textField: UITextField!) -> Bool { //delegate method
textField.resignFirstResponder()

return true
}

关于ios - 使用 Swift 实现 UITextFieldDelegate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24171857/

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