resignFirstResponder not hiding keyboard on textFieldShouldReturn

后端 未结 14 1745
我在风中等你
我在风中等你 2020-12-05 10:11

I have a view with a UITextField which should hide the keyboard when return is pressed.

My function is this:

- (BOOL)textFieldShouldReturn:(UITextFie         


        
14条回答
  •  难免孤独
    2020-12-05 10:42

    Swift 3.0

    func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
    
        if textField == addressTextField {
            textField.resignFirstResponder()
    
            return false
        }
    
        return true
    }
    

提交回复
热议问题