我有UITextField
。我将UIDatePicker
设置为此UITextField
的inputView
UITextField *dateField = [[UITextField alloc] init];
dateField.frame = CGRectMake(30, 180, 260, 30);
dateField.delegate = self;
[self addSubview:dateField];
UIDatePicker *datePicker = [[UIDatePicker alloc]init];
[datePicker setDate:[NSDate date]];
datePicker.frame = CGRectMake(0, 568 - 100, 320, 100);
[datePicker addTarget:self action:@selector(updateTextField:) forControlEvents:UIControlEventValueChanged];
[dateField setInputView:datePicker];
-(void)updateTextField:(id)sender
{
NSLog(@"SENDER = %@", sender);
}
有什么办法可以在
UITextField
方法中获取updateTextField
最佳答案
添加它并创建ivar currentTextField
- (void)textFieldDidBeginEditing:(UITextField *)textField {
currentTextField = textField;
}
updateTextField中的currentTextField将是您的文本字段