In my application i want to textField where user c开发者_StackOverflowan 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
UIDatePicker will allow the user to easily select the date.
uidatepicker and take the value changed
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.
精彩评论