Joris Weimar
Joris Weimar

Reputation: 4921

UITextField in UITableViewCell

I have a standard UITableViewController. In the cellForRowAtIndexPath I add a subview to cell.contentView. This UIView itself contains a UITextField object. This object will not respond to touches. I have set the delegate to the UIView and implemented all the methods. I have also set userInteractionEnabled = YES. When I tap the UITextField nothing happens! I feel it's being absorbed by the cell. What would be the easiest, least messy fix?

Best, Joris

EDIT: Sorry, see my answer. I solved it.

Upvotes: 0

Views: 816

Answers (4)

Joris Weimar
Joris Weimar

Reputation: 4921

I'm an idiot. Sorry for wasting everyone's time. I hadn't properly said the UIView's frame. It of course did display the UI elements, but wouldn't respond to them.

Upvotes: 1

Narayanan
Narayanan

Reputation: 785

Try setting the editing property of the table view to YES. Check this answer

Editing a UITextField inside a UITableViewCell fails

Upvotes: 0

MatLecu
MatLecu

Reputation: 953

In your tableView, try to set

allowsSelection = NO;

Upvotes: 0

Dan F
Dan F

Reputation: 17732

Try just adding the textfield as a subview of the cell, this is what I have done in a couple of my apps and had no problems with it

Upvotes: 0

Related Questions