1

I have a custom tableView cell with a textfield. Now, I want to recognise the textField outside of the tableView delegate method. I tried this-

UIView *cell = textField;
[cell isKindOfClass:[UITableViewCell class]];

but it's not working.

Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

0

To get concrete cell from table view you need to know index path of this cell. Then you need to do:

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];  //you should set your indexes of row and section instead of zeros
MyCustomCell *cell = [myTableView cellForRowAtIndexPath:indexPath];

Now if text field is a property of your custom cell you can get it using cell.myTextField

For example:

UITextField *textField = cell.myTextField;

Now you can do what you want with it.

Victorianec
  • 587
  • 1
  • 6
  • 15