i have a form wher i need to enter the start date and end date to view the transactions. when i set the focus on the textfirld, i can see the keypad, but behind it the datepicker is coming. how am i remove the keypad and only show the datepicker
A:
you can call [myTextField resignFirsrResponder] on some button click method or, for example, in textFieldShouldReturn delegate method. smth like that
- (BOOL)textFieldShouldReturn:(UITextField *)textField{ [textField resignFirstResponder]; return YES; }
Morion
2009-11-10 10:25:36
i dont want to add a button , and then dismiss the keypad.simply on clicking the textfield it should display the datepicker
shreedevi
2009-11-10 10:38:16
textFieldShouldReturn: delegate method called after "Return" button of keyboard was pressed.
Morion
2009-11-10 10:58:53
you mean to say that every time i set the focus on the text field, the keypad will be shown, and when i press the return button, i will be shown the datepicker.
shreedevi
2009-11-10 11:01:52
I mean that every time you will press return button, keyboard will hide. and after setting the focus to the text field it will be shown.
Morion
2009-11-10 11:36:31
+1
A:
It sounds like instead of a standard keypad, you instead want to show your own datepicker view. I believe you can handle that by setting the delegate for your textfield then providing textFieldShouldBeginEditing.
// in viewWillAppear set the textfield delegate if needed
...
myTextField.delegate = self;
...
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
// if date picker not in display, show it here...
return NO;
}
wkw
2009-11-10 13:09:22
A:
Hi, I struggled with that myself and found the solution. You can do it this way:
- (void)viewDidLoad
{
[super viewDidLoad];
// set delegate for date text field
dateField.delegate = self;
}
// Display the picker instead of a keyboard
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
[self showDatePicker];
return NO;
}
This assumes, that you have declared a method called showDatePicker, which handles the UIPicker display.
Chris
2009-12-09 21:54:31