sale lanzamiento fecha descargar cuando compatibilidad iphone keyboard focus uitextfield

lanzamiento - ios 12 iphone 7



¿Cómo establecer el foco en el próximo uitextfield en iPhone? (3)

Pruebe esta notificación de agregado en ViewDidLoad,

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(limitTextField:) name:@"UITextFieldTextDidChangeNotification" object:txtField1]; - (void)limitTextField:(NSNotification *)note { if(txtField1.tag==1) { if ([[txtField1 text] length] > 1) { [txtField1 resignFirstResponder]; [txtField2 becomeFirstResponder]; } } }

Tengo 8 uitextfields que son para una contraseña. Cada campo de texto contiene una letra de la contraseña. Cuando escribo una letra y luego de eso cuando presiono la 2da tecla, el foco se mueve al siguiente campo de texto. Pero quiero que, tan pronto como termine de escribir el primer carácter, el foco se mueva al siguiente campo de texto sin presionar otra tecla o presionar la tecla tab. ¿Cómo puedo hacer eso? ¿Algún tutorial de código de muestra para eso? El código que he usado es el siguiente.

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(keyPressed:) name: UITextFieldTextDidChangeNotification object: nil]; // Try to find next responder UIResponder* nextResponder = [textField.superview viewWithTag:nextTag]; if (nextResponder) { // Found next responder, so set it. //nextTag += 1; [nextResponder becomeFirstResponder]; if ([nextResponder tag] == 308) { //[self performSelector:@selector(checkPassCode) withObject:nil afterDelay:0.0]; [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(checkPassCode) userInfo:nil repeats:NO]; lastResponder = nextResponder; } return YES; } else { [textField resignFirstResponder]; return NO; } } -(void) keyPressed: (NSNotification*) notification { nextTag += 1; [[NSNotificationCenter defaultCenter] removeObserver: self name:UITextFieldTextDidChangeNotification object: nil]; }


- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { NSString *finalString = [textField.text stringByReplacingCharactersInRange:range withString:string]; if ( [finalString length] > 0 ) { textField.text = string; UIResponder* nextResponder = [textField.superview viewWithTag:(textField.tag + 1)]; if (nextResponder) { [nextResponder becomeFirstResponder]; // Your code for checking it. } return NO; } return YES; }

Espero que esto ayude.


-(BOOL)textFieldShouldReturn:(UITextField *)textField { if (textField ==firstTextField) { [secondTextField becomeFirstResponder]; }else if ( textField == secondTextField){ [thirdTextField becomeFirstResponder]; }else if ( textField == thirdTextField){ [fourthTextField becomeFirstResponder]; }else{ [textField resignFirstResponder]; } return YES; }