Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want a UItextField that is in UITableViewCell to become first responder only when the cell touched

This is what I'm trying to achieve:

I want a UITextField that is in UITableViewCell to become first responder only when the cell touched. I would like the text field to become the first responder only when I set it to first responder in the method:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath`

Any idea how I can achieve this? When the textfield is touched directly, tableView:didSelectRowAtIndexPath: is never called.

Thanks in advance.

like image 476
Darren Findlay Avatar asked Jul 07 '11 16:07

Darren Findlay


1 Answers

I guess, u have a custom UITableViewCell. In that u could have a UITextField member. Right?

In the custom cell class, override the method,

- (void)setSelected:(BOOL)selected animated:(BOOL)animated:

In that , if selected == YES, then make the text field as first responder. Else , resign the first responder.

like image 114
Ilanchezhian Avatar answered Sep 24 '22 19:09

Ilanchezhian