I'd like to call UIDatePicker only when UITextField is active. When the date is picked, it should be shown in the same UITextField.
I even don't know how to call the Picker.
Can anyone help me?
there is a delegate method called
-(void)textFieldDidBeginEditing:(UITextField*)textField
{
[textField resignFirstResponder];
in this you have to do this
pick = [[UIDatePicker alloc] init];
[pick setFrame:CGRectMake(0,200,320,120)];
[pick addTarget:self action:@selector(done) forControlEvents:UIControlEventValueChanged]
[self.view addSubview:pick];
}
in
-(void)done
{
[textfield setText:pick.date];
}
release the pick in dealloc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With