Reputation:
I need to invoke a UIDatePicker when i tap on a textfield. Usually when we tap on a textfield the keyboard pops up. But I need a date picker instead of that. Can anyone help me please...!
Thank you in advance.
Upvotes: 1
Views: 1739
Reputation: 21760
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]);
Upvotes: 1
Reputation: 25429
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.
Upvotes: 0