iphoneuitextfielduikeyboarduipicker

How to resign or hide the keyboard?


I have a pick list to select a day and a text field to show the selected date. It will be like this...

alt text

If i choose any date, it will be like this....

alt text

The cross symbol in text field is acheived by the code....

textField.clearButtonMode=UITextFieldViewModeAlways;

Now my problem is, while clicking on this cross button, a keyboard was displayed. This is like....

alt text

But i want the cross button only for erase the text field. The keyboard should not come. Is it possible?


Solution

  • On your UITextFieldDelegate, implement the method - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField and return NO;

    - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
    return NO;
    }