Chilly Zhong
Chilly Zhong

Reputation: 16793

Can I add action to 'Done' button on input pad on iPhone?

There is a 'Done' button on the input pad on iphone, but there is no action to it by default. Can I add an action to it? For example, hide the input pad when 'Done' is pressed?

Upvotes: 1

Views: 1182

Answers (1)

Andrew Grant
Andrew Grant

Reputation: 58804

In your keyboard delegate you need to give up the focus. E.g

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

This works for both the done and return keys.

Upvotes: 6

Related Questions