f0rz
f0rz

Reputation: 1565

UITextField in UITableView to becomeFirstResponder

I have a problem which I dont have a clue how to work around. Maybe anyone of you could help me to the correct directions...

Simple I have a UITableView with each cell containing a UITextField. When I´m editing a cell (UITextField) and hit Return Key, a new row is inserted under the current cell. After that I reloadData on the TableView, the new row is showed. Everything is OK here.

Now to my problem, I want to [UITextField becomeFirstResponder] on the newest added row. But I could not find anyway to accomplish this. I could post code but didn't find that necessary.

Cheers.

Upvotes: 1

Views: 1402

Answers (1)

schaechtele
schaechtele

Reputation: 1130

You should somehow be able to get the indexPath of the last inserted row. If you have this indexPath you can call the cellForRowAtIndexPath: method of the tableView.

Now you have the last inserted cell and can call the becomeFirstResponder method of the textfield (do you have a custom made cell?).

Upvotes: 2

Related Questions