user346443
user346443

Reputation: 4852

IOS keyboard enter selector

On IOS where do i hook up a selector to the keyboards enter button?

Cheers

Upvotes: 4

Views: 4147

Answers (3)

iH7q5n
iH7q5n

Reputation: 19

Add UITextFieldDelegate to your .h and add bellow code to your .m:

-(BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
return YES;
};

Upvotes: 1

Christian
Christian

Reputation: 1714

In the textFieldShouldReturn method listed by Till, you would do

[textField resignFirstResponder];

to hide the keyboard.

Upvotes: 4

Till
Till

Reputation: 27597

Use the UITextFieldDelegate-Protocol and implement:

-(BOOL)textFieldShouldReturn:(UITextField *)textField

See the UITextFieldDelegate Reference.

Upvotes: 9

Related Questions