当用户点击UITextField然后点击直接开始与UIDatePicker控件交互时,我似乎无法解除键盘。
我正在使用以下功能来点按键盘:
// The following code will remove the keyboard when it is not editing...
var g = new UITapGestureRecognizer(() => View.EndEditing(true));
View.AddGestureRecognizer(g);
当用户点击UIDatePicker控件开始调整日期时,能否告诉我如何解除键盘?
答案 0 :(得分:0)
您必须在ui元素上调用.ResignFirstResponder()
。这应该会解雇键盘。
xamarin recipe example for keyboard dismissing
xamarin documentation explaining ResignFirstResponder
答案 1 :(得分:0)
试试这段代码:
var tap = new UITapGestureRecognizer ();
tap.AddTarget (() => this.View.EndEditing (true));
this.View.AddGestureRecognizer (tap);
tap.CancelsTouchesInView = false;