当用户按下背景时,我想关闭我的数字键盘。我的问题是我找不到调用 ResignFirstResponder 的文本字段。我正在使用 MonoTouch.Dialog。因为我可以覆盖 InputAccessoryView,所以这是我的代码:
using System;
using MonoTouch.Dialog;
using MonoTouch.UIKit;
using System.Drawing;
namespace MyApp
{
public class JMADialogViewController : DialogViewController
{
public JMADialogViewController (RootElement root, bool pushing) : base(UITableViewStyle.Grouped, root, pushing)
{
}
UIView dismiss;
public override UIView InputAccessoryView
{
get
{
if (dismiss == null)
{
dismiss = new UIView(new RectangleF(0,0,320,27));
dismiss.BackgroundColor = UIColor.Black;
UIButton dismissBtn = new UIButton(new RectangleF(255, 2, 58, 23));
dismissBtn.SetTitle("Done", UIControlState.Normal);
dismissBtn.TouchDown += delegate {
//textField.ResignFirstResponder();
dismiss.ResignFirstResponder();
};
dismiss.AddSubview(dismissBtn);
}
return dismiss;
}
}
}
}