Ian Vink
Ian Vink

Reputation: 68770

MonoTouch.Dialog: Dismissing a Keyboard

Using the Reflection API to auto generate a UI.

How can I dismiss the keyboard when the user selects a new field, or if they choose a field which generates a new view to pick from. In the later case, when the user returns to the first screen, the old keyboard is still there.

Upvotes: 3

Views: 2069

Answers (3)

benhorgen
benhorgen

Reputation: 1955

Clarification for those initially struggling with the MonoDialog portion of the question:

The EndEditing method is not available on DialogViewControllers objects directly (who inherit from UITableViewControllers). You should be calling EndEditing(bool) on the View of a DialogViewController and not trying to call EndEditing(bool) on the actual DialogViewController itself.

For clarification:

DialogViewController dc; dc.View.EndEditing(true);

Note: UIView objects include the EndEditing(bool) method, but UITableViewControllers do not inherit from UIView so the EndEditing method is not available on the controller itself. UITableViewControllers contain a view object, call EndEditing on that view object.

Upvotes: 5

BLeB
BLeB

Reputation: 1746

UIView.EndEditing(bool force);

The above will hide the keyboard for you without needing to know who the first responder is. I haven't done much with the reflection API but you should be able to call that on the view when an element is selected.

Apple Docs -- endEditing:

Upvotes: 9

Scarlaxx
Scarlaxx

Reputation: 835

Check the ResignFirstResponder method. This one should help you I guess.

Upvotes: 0

Related Questions