asedra_le
asedra_le

Reputation: 3067

How to make "dismiss keyboard" on iPhone?

Anybody can tell me how to add "dismiss key" to iPhone's virtual keyboard?

Upvotes: 4

Views: 1132

Answers (2)

Luke
Luke

Reputation: 3655

You can add an InputAccessoryView which will sit on top of the virtual keyboard (the height is adjustable but the width will always be the width of the keyboard).

If you open the Safari app, when you tap into a textfield, you'll see a bar above the keyboard, this is an example of an InputAccessoryView

On this accessory view, you can add a button, that when clicked will resign first responder to all of all the appropriate fields on the current view. This will dismiss the keyboard, no matter what what is currently in focus.

Upvotes: 3

knuku
knuku

Reputation: 6102

I doubt it is a proper way to add button to a standard keyboard. You should add a button to your view which "tells" your controller (via addTarget...) to send resignFirstResponder message to the text field or search bar that has called the keyboard

Upvotes: 0

Related Questions