views:

654

answers:

4

Hi all, I need to invoke a UIDatePicker when i tap on a textfield. usually when we tap on a textfield the keyboard pop ups. but i need a date picker instead of that. can anyone help me please...!

Thank you in advance.

A: 

A textfield is a control you use for text input. This is why tapping on it the keyboard pops up. If you need a date picker, simply use directly a date picker if you have space in your view, otherwise use a button and set the target-action of the button so that it shows a new view containing your date picker.

unforgiven
Thanks... i implemented a button for that.. can you please tell me how to remove the time from the string which i get from the date picker. I just need the date.Thanks
Shibin Moideen
+1  A: 

UIDatePicker returns NSDdate. Use NSDateFormatter to get the string you want:

NSDateFormatter *format = [[NSDateFormatter alloc] init];
[format setDateFormat:@"yyyy-MM-dd"];
NSLog(@"%@", [format stringFromDate:newDate]);
Jordan
Thanks Jordan , thanks a lot.. it works...
Shibin Moideen
Feel free to vote up the correct answer
Jordan
A: 

Hi, I'm very new with iPhone development and I'm looking for the same thing for a little project. Shibin, could please send me a little project where you implement this functionnality? That will help me.. I thank you in advance. Stan

Stan92