Mann
Mann

Reputation: 5507

iphone application linking calendar with textfield

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

Answers (3)

Ben Mosher
Ben Mosher

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

koti
koti

Reputation: 81

uidatepicker and take the value changed

Upvotes: 1

rckoenes
rckoenes

Reputation: 69469

UIDatePicker will allow the user to easily select the date.

Upvotes: 1

Related Questions