开发者

iphone application linking calendar with textfield

开发者 https://www.devze.com 2023-03-25 08:40 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消