Reputation: 3854
I have a method called -(IBAction)setPicker:(id) sender
Basically this method substitutes a keyboard into a datePicker when called upon. I want this to happen (aka the method setPicker to be called) as soon as the user touches the text field trying to input something. The problem is that no matter what event I link it too, it does not end up calling the method.
I tried connecting the text field to the event "touch up inside" (thought I could do it the same way as I would for a button but no luck).
Does anyone have any suggestions or ideas on how this can be done?
Thanks!
Upvotes: 0
Views: 220
Reputation: 2514
Have you set the Delegate to your Textfield..
textField.delegate = self;
I have just use this method to do the same :-
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
return NO;
}
Hope it helps you..
Upvotes: 0
Reputation: 965
If you want show UIDatePicker (or any other view) instead of keyboard when editing UITextField, you can do following:
UITextField* textField = ...; // your textfield
UIDatePicker* picker = ...; //your picker (or any other view)
textField.inputView = picker;
Upvotes: 0
Reputation: 17478
Implement UITextFieldDelegate.
Implement the method
- (void)textFieldDidBeginEditing:(UITextField *)textField
from UITextFieldDelegate
.
Show your datepicker when this delegate method get called.
Upvotes: 1
Reputation: 5540
There is a delegate method for the UITextField .
(i.e `- (void)textFieldDidBeginEditing:(UITextField *)textField)`
Upvotes: 0