Note that there are some explanatory texts on larger screens.

plurals
  1. POSeveral UITextField, need to switch between keyboard and UIDatePicker
    primarykey
    data
    text
    <p>in my view I have several UITextFields and I need to show some times a keybord for text input and other times a UIDatePicker.</p> <p>I order to show a DatePicker I implemented the delegate for the date UITextField, but once I select another UITextField for text input the DatePicker remains in background. Then I tried to implement the delegate also for another UITextField, with this code:</p> <pre><code>- (void)viewDidLoad { NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"dd/MM/yyyy"]; NSString *stringFromDate = [formatter stringFromDate:[NSDate date]]; NSLog(@"IN - AddExpenseViewController::viewDidLoad %s",stringFromDate); date.text = stringFromDate; datePicker.hidden = YES; date.delegate = self; amount.delegate = self; isIncome = NO; [super viewDidLoad]; } </code></pre> <p>// ...</p> <pre><code>- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{ NSLog(@"IN - AddExpenseViewController::textFieldShouldBeginEditing %@",textField.placeholder); if (![textField.placeholder isEqual:[NSString stringWithFormat:@"Date"]]) { [self hideDatePicker]; [textField becomeFirstResponder]; return YES; } else { [self showDatePicker]; } return NO;} </code></pre> <p>The problem is that when I select the date TextField and than the amount, the delegate gets called in loop:</p> <p>2010-12-05 13:15:17.324 AddExpense[1179:207] IN - AddExpenseViewController::textFieldShouldBeginEditing Amount 2010-12-05 13:15:17.324 AddExpense[1179:207] IN - AddExpenseViewController::hideDatePicker 2010-12-05 13:15:17.325 AddExpense[1179:207] IN - AddExpenseViewController::textFieldShouldBeginEditing Amount 2010-12-05 13:15:17.326 AddExpense[1179:207] IN - AddExpenseViewController::hideDatePicker 2010-12-05 13:15:17.327 AddExpense[1179:207] IN - AddExpenseViewController::textFieldShouldBeginEditing Amount 2010-12-05 13:15:17.327 AddExpense[1179:207] IN - AddExpenseViewController::hideDatePicker</p> <p>and there is no way to stop it ! What is wrong with my code ?</p> <p>Thanks in advance, AM</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload