How to programmatically release the keyboard in Monotouch

There are many examples of how to do this in native Objective-C, but I cannot find an example of how to do the same in C # code in MonoTouch.

I would like to remove the keyboard that appears when the user presses the return key.

Is EditingDidEnd the right trap event? I can't seem to find a call to the response method of the first responder.

Help get a high rating.

+3
source share
3 answers

Look here for a sample.

, , . , , , MonoTouch. , / .

+3

, , . 1LOC

myTextField.SetKeyboardEditorWithCloseButton(UIKeyboardType.NumberPad); 

:

public static void SetKeyboardEditorWithCloseButton (this UITextField txt, UIKeyboardType     keyboardType, string closeButtonText = "Done")
{
    UIToolbar toolbar = new UIToolbar ();
    txt.KeyboardType = keyboardType;
    toolbar.BarStyle = UIBarStyle.Black;
    toolbar.Translucent = true;
    toolbar.SizeToFit ();
    UIBarButtonItem doneButton = new UIBarButtonItem (closeButtonText, UIBarButtonItemStyle.Done,
                                                      (s, e) => {
        txt.ResignFirstResponder ();
    });
    toolbar.SetItems (new UIBarButtonItem[]{doneButton}, true);

    txt.InputAccessoryView = toolbar;
}

http://moocode.net/img/numeric_editor.png

+3

TouchesBegan() textbox.ResignFirstReponder() , , View.EndEditing(true);. , , - UIViewController .

0

All Articles