Note that there are some explanatory texts on larger screens.

plurals
  1. POAutomatically change UITextField when reach determine length
    text
    copied!<p>Hi I have 3 <code>UITextFields</code> and I want to change automatically to the next <code>textfield</code> when the user enters 3 characters. I manage to limit the length of one of the <code>textfields</code> that has a normal keyboard input, for the other 2 that have a numeric keypad I could limit the length.</p> <p>Here is what I have for one of the <code>textfield</code> to limit the length:</p> <pre><code>-(BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string </code></pre> <p>{</p> <pre><code>if (dia.text.length &gt;= 2 &amp;&amp; range.length == 0) { [self.mes becomeFirstResponder]; // esto activa el siguiente textfield return NO; } if(mes.text.length &gt;= 3 &amp;&amp; range.length == 0) { [self.anio becomeFirstResponder]; // esto activa el siguiente textfield return NO; } if (anio.text.length &gt;= 4 &amp;&amp; range.length == 0) { [self.hora becomeFirstResponder]; // esto activa el siguiente textfield return NO; } if (hora.text.length &gt;= 2 &amp;&amp; range.length == 0) { [self.minutos becomeFirstResponder]; // esto activa el siguiente textfield return NO; } return YES; </code></pre> <p>}</p> <p>EDIT: on viewDidLoad I have this 5 lines if I remove them the limit doesn't work on anyone but if I leave them I only can input text on just one text field:</p> <pre><code>self.dia.delegate = self; self.mes.delegate = self; self.anio.delegate = self; self.hora.delegate = self; self.minutos.delegate = self; </code></pre>
 

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