Reputation: 5507
In my application i want to textField where user can put date. Now for taking date i need calendar so that user select date from it and it automatically fill into textField. What would be the best approach to do so.
Thanks
Upvotes: 0
Views: 392
Reputation: 13381
I built a fancy UITextField
class that set up a UIDatePicker
as its inputView
. The main value to this is that, when the user taps into the text field, the date picker is brought up where the keyboard would normally be.
UIDatePicker *input = [[UIDatePicker alloc] init];
[input addTarget:self action:@selector(update:) forControlEvents:UIControlEventValueChanged];
(UITextField *)myTextField.inputView = input;
[input release];
Then, in the -[update:]
method, use an NSDateFormatter
to set the text in the textfield.
Upvotes: 1