我写了一个简单的 iOS 应用程序只是为了学习,在我的情况下我需要使用 aUIDatePicker
并且,在用户更改日期后,我需要将此日期写入 a UITextField
,这是代码:
.h 文件
@interface ExpenseViewController: UIViewController<UITextFieldDelegate>
@property (strong,nonatomic) IBOutlet UITextField *editTextDate;
- (void) updateTextFieldDate:(UIDatePicker *)pickerL;
@end
.m
@implementation ExpenseViewController
@synthesize ediTextDate;
- (void) viewDidLoad
{
[super viewDidLoad]
UIDatePicker *datePicker;
datePicker = [[UIDatePicker alloc]init];
[datePicker setDate:[NSDate date]];
[datePicker setDatePickerMode:UIDatePickerModeDate];
[datePicker removeTarget:self action:nil forControlEvents:UIControlEventValueChanged];
[datePicker addTarget:self action:@selector(updateTextFieldDate:) forControlEvents:UIControlEventValueChanged];
[editTextDate setInputView:datePicker];
}
- (void) updateTextFieldDate:(UIDatePicker *)pickerL{
UIDatePicker *picker=(UIDatePicker*)self.editTextdate.inputView;
editTextDate.text=[NSString stringWithFormat:@"%@",picker.date];
}
@end
但我收到了这个错误:
ExpenseViewController updateTextFieldDate:]:unrecognized selector sent to instance 0x8d395f0
谁能帮我?
谢谢。