Reputation: 1656
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
Upvotes: 2
Views: 2053
Reputation: 9098
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];
Upvotes: 3