aresz
aresz

Reputation: 2649

Make UITableViewCell not selectable, but make the textfield on it selectable

I have a static UITableView with 2 rows. I placed a UITextField on those rows for user input. How do I make the UITableViewCells not selectable but still make the UITextField on it user-interactable?

I tried disabling the "User Interaction Enabled" property of the cell in the Inspector pane. As a result, I'm not able to select/highlight the row/cell which is what I want. But I'm not able to interact with the UITextField to input data.

The only solution I can think of right now is to increase the size of the textfield and match the size of the cell so that it completely 'covers' the cell.

Is there a better way of doing this?

Upvotes: 0

Views: 1437

Answers (1)

TreeTree
TreeTree

Reputation: 557

Do NOT implement, or leave the following delegate method blank:

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

And disable the selector style for the cell by:

[cell setSelectionStyle:UITableViewCellSelectionStyleNone];

Upvotes: 3

Related Questions