resignFirstResponder not hiding keyboard on textFieldShouldReturn

后端 未结 14 1693
我在风中等你
我在风中等你 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:45

    If you are using the Interface Builder, look if your UITextField has the delegated linked with your class.

    -Select your UITextField and in your Connections look if exits one connection in Outlets->delegate. If not, conect with you File's Owner Class.

    This need to be linked with your File's Owner Class. This delegate tell where to search for a method. If your are overriding a method, you need to tell where the object will search for that.

    0 讨论(0)
  • 2020-12-05 10:46

    I was having the same problem. I realized that after connecting the delegate to the File's Owner in Interface Builder, I neglected to save in Interface Builder. Once I saved, I recompiled and the keyboard disappears correctly when hitting return.

    0 讨论(0)
提交回复
热议问题