2

Very beginner obj-c question.

Is it a possibility to ask about who is first responder at the moment? I have a tableView with four custom cells and with textfield in every cell. Link

I tagged textFields from 1 to 4. And I need to realise the possibility of switching between textfields with buttons 'Next' and 'Previous' . So ,for example, in code of button 'Next' I need something like this:

    if ([[txtfld.tag == 1] isFirstResponder) 
    {
     [[txtfld.tag == 2] becomeFirstResponder];
    }

But this code isn't worked because I don't know how to call textField from method where it's not visible. Is it a right way of thinking to resolve this problem, or maybe there is a better approach?

Thanks, Alex

1

1 Answer 1

3

You will need to get reference to your UITableViewCell and then you can use the -viewWithTag method. For example UITextField *textField = (UITextField *)[cell viewWithTag:1];

Then you can check [textField isFirstResponder];

1
  • What do you mean to get reference? To set property or set delegate?
    – Olex
    Oct 31, 2012 at 18:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.