tags:

views:

1267

answers:

4

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
i dont want to add a button , and then dismiss the keypad.simply on clicking the textfield it should display the datepicker
shreedevi
textFieldShouldReturn: delegate method called after "Return" button of keyboard was pressed.
Morion
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
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
+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
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
A: 

Use these two links.

http://developer.apple.com/iphone/library/samplecode/DateCell/Introduction/Intro.html#//apple_ref/doc/uid/DTS40008866

black2842
andhttp://www.iphonesdkarticles.com/2009/01/uitableview-searching-table-view.htmlI spent hrs banging my head trying to get it to work and finally it worked.Hope this helps
black2842