0

I've an issue need to help. My issue is: I have 3 text field in view. Currently, the cursor put at text field (3). The user can touch done button on the keyboard. When done button I've checked format valid. Assume, text field 2 is not valid format type (show uialertview), when I touch "OK" button on UIAlertview the cursor will be back from text field 3 to text field 2. Could you help me to solve problem touch OK Aleart view and back cursor from text field 3 to text field 2?

Cuong Nguyen
  • 980
  • 2
  • 9
  • 29
  • Please add some code to illustrate your problem a little better. – caseynolan Dec 16 '15 at 11:04
  • Is it not just check then `[yourTextField becomeFirstResponder]`? – Tj3n Dec 16 '15 at 11:15
  • You see this page [http://stackoverflow.com/questions/764179/focus-a-nstextfield](http://stackoverflow.com/questions/764179/focus-a-nstextfield) – Moosa Dec 20 '15 at 09:17
  • You can see thi spage [http://stackoverflow.com/questions/764179/focus-a-nstextfield](http://stackoverflow.com/questions/764179/focus-a-nstextfield) – Moosa Dec 20 '15 at 09:18

2 Answers2

1

In the OK button handler of your AlertView write the following code

 [textField2 becomeFirstResponder];
Muneeba
  • 1,756
  • 10
  • 11
0
  1. When you create Alertview give the delegate to self of that alert view.

    YourAlertView.delegate = self;

  2. Add delegate of Alertview to handle the button event of alert view.

If you have multiple Alertview then you should give them tag and differentiate according tags.

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 0)
    {
        [textFiled2 becomeFirstresponder];
    }
}
Jaimish
  • 629
  • 5
  • 15
  • I used cell and create textField2 and then reused it on cell. I init it in cell for row at indexpath. Here is my code `UITextField *inputTextField = (UITextField *)[cell viewWithTag:2]; switch (indexPath.row) { case 1: inputTextField.keyboardType = UIKeyboardTypeEmailAddress; inputTextField.text = _email; break; default: inputTextField.returnKeyType = UIReturnKeyDone; inputTextField.text = _companyName; break; } [inputTextField becomeFirstResponder];` – Cuong Nguyen Dec 16 '15 at 14:55
  • So what's your issue now? – Jaimish Dec 17 '15 at 05:02
  • how to call textField2 on alertView when i create text field 2 in function cellForRowAtIndexPath – Cuong Nguyen Dec 17 '15 at 07:24
  • I just want to put textfield in alertview delegate. – Cuong Nguyen Dec 17 '15 at 07:42
  • want to create textfield? – Jaimish Dec 17 '15 at 08:38
  • no, I wanna put text field from function cellForRowAtIndexpath to function alertView didDismissWithButtonIndex: – Cuong Nguyen Dec 17 '15 at 11:06