📜  swift 5 on return 按钮动作 - Swift 代码示例

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

代码示例1
Swift 5:
class YourClass: UIViewController, UITextFieldDelegate {
  
      // will trigger when return button from keyboard is pressed
    func textFieldShouldReturn(_ textField: UITextField) -> Bool {
        performAction(textField)
        return true
    }
  
      private func preformAction(_ textField:UITextField){
        //... code here ...
    }
}