我寫一個簡單的iOS應用只是爲了學習,在我來說,我需要使用一個UIDatePicker
和,之後用戶更改日期,我必須在這一天寫入一個UITextField
,下面的代碼:的UIDatePicker事件改變
.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
任何人都可以幫助我嗎?
謝謝。
備註 - 沒有理由在.h文件中聲明'updateTextFieldDate:'。 – rmaddy 2013-05-09 17:58:07