Search code examples
iosobjective-cuitableviewcustom-cellnsindexpath

get UITableViewCell from NSIndexPath?


I am using multiple UITableView with custom cells in a single viewController. Custom cell have textFields, I am able to edit the textFields. Now I want to get the tableViewCell of exact UITableView in the textField delegate method when am editing the textField ?

Remember there are multiple tableViews I want to get the exact cell of exact table which am editing. Any Help?


Solution

  • You must have tag to your both tableview

    use below code in textfield delegate

    UITableViewCell *cell = (UITableViewCell *) textField.superview.superview.superview;
    UITableView *curTableView = (UITableView *)cell.superview;
    NSIndexPath *indexPath = [curTableView indexPathForCell:cell];