Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Telling a UITextField to become first responder while embedded in a UITableViewCell

I have a UITextField that is a subview of a UITableViewCell.

When my view loads, I want the text field to become first responder. I have a pointer to the text field in the table cell, so to do this I am trying:

[myTextField becomeFirstResponder]; 

This returns NO all the time, regardless of when it's called, which according to the docs means the text field refused to become first responder... What am I doing wrong?

Edit:

The textfield properly responds to being touched. It bring up the keyboard then. It's only when telling it to becomefirstresponder programmatically that the problem happens.

like image 718
Jasarien Avatar asked Nov 14 '09 00:11

Jasarien


1 Answers

It turned out that the text field was nil when I was trying to send it first responder. Sending becomeFirstResponder later in the life cycle worked.

like image 100
Jasarien Avatar answered Oct 01 '22 06:10

Jasarien