简体   繁体   中英

Unable to refocus UITextField after storing pointer and resigning first responder

I am working with a grouped UITableView each containing a subclassed UITextField as its content view. The subclassed UITextField only contains an additional property indexPath to store its position within the table.

The issue I face is that I want to record which text field is the current responder so I added a UITextField property to my view controller. I implemented the textFieldDidBeginEditing delegate method and when the method is called the textField pointer argument is stored as the first responder property of my view controller.

When in use the field is initially focusable, however if I end editing by pushing Return on the keyboard, the keyboard disappears and I am no longer able to bring the focus back to the original text field or any of the other text fields in the table.

If I remove the line self.firstResponder = (LKCTableViewTextField *)textField; from the textFieldDidBeginEditing delegate method all works as expected but I do not have the pointer to the text field set as first responder.

Has anyone had this issue or know of what's going on?

Thanks,

Eric

Ok, sorry not understood correctly, to see if it serves you to save a reference to textfield.

- (void)textFieldDidBeginEditing:(UITextField *)textField
{
    activeField = textField;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM