I am trying to implement an OTP system in iOS. After getiing OTP (One Time Password) I am trying to change the cursor of keyboard but the cursor is shifting after typing in keyboard twice. For the first textfield it is working fine but while trying to add in the second textfield it is not working until I press any charecter from keyboard.
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if(textField==_txtOtpOne)
{
if(textField.text.length==1)
{
[_txtOtpTwo becomeFirstResponder];
}
}
else if(textField==_txtOtpTwo)
{
if(textField.text.length==1)
{
[_txtOtpThree becomeFirstResponder];
}
}
else if(textField==_txtOtpThree)
{
if(textField.text.length==1)
{
[_txtOtpFour becomeFirstResponder];
}
}
else if(textField==_txtOtpFour)
{
if(textField.text.length==1)
{
}
}
return YES;
}
Please help me out. Thanks in advance.