开发者

MonoTouch.Dialog: Dismissing a Keyboard

开发者 https://www.devze.com 2023-04-04 11:39 出处:网络
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. I

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.


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:


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号