MonoTouch.Dialog: Dismissing a Keyboard
Asked Answered
F

3

3

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.

Fourflusher answered 13/9, 2011 at 21:44 Comment(0)
I
9
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:

Intermit answered 10/11, 2011 at 16:13 Comment(0)
S
5

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.

Spelldown answered 13/6, 2012 at 21:10 Comment(0)
P
0

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

Profane answered 16/9, 2011 at 9:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.