📌  相关文章
📜  xcode 在返回键按下文本字段时执行操作 - Swift 代码示例

📅  最后修改于: 2022-03-11 15:01:03.544000             🧑  作者: Mango

代码示例1
class SomeViewControllerClass : UIViewController, UITextFieldDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()

        self.textField.delegate = self
    }

    func textFieldShouldReturn(textField: UITextField) -> Bool {

        //textField code

        textField.resignFirstResponder()  //if desired
        performAction()
        return true
    }

    func performAction() {   
        //action events
    }
}