Question

I have a custom cell with a textfield. Initially it displays no disclosure indicator. When the textfield editing begins, I want to display a disclosure indicator (custom image). When textfield editing ends, I want to hide the disclosure indicator.

Here is what I have tried:

Assign the textField and cell the same tag as indexPath.row of the cell and add selector:

[cell.textField addTarget:self
                   action:@selector(textFieldDidBecomeActive:)
         forControlEvents:UIControlEventEditingDidBegin];

Then in textFieldDidBecomeActive

switch (textField.tag)
{
    case TO_CELL:
    {
        static NSString *CellIdentifier = @"MPTToCell";
        MPTToCell* cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];

        if (cell == nil)
            cell = [[MPTToCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

        cell.disclosure.image = [UIImage imageNamed:@"addEmail.png"];
// Some more code 
    }
// Some more code 
}
NSIndexPath* tempPath = [NSIndexPath indexPathForItem:textField.tag inSection:0];
NSArray* tempPathArray = [[NSArray alloc]initWithObjects:tempPath, nil];
[self.tableView beginUpdates];
[self.tableView reloadRowsAtIndexPaths:tempPathArray withRowAnimation:UITableViewRowAnimationNone];
[self.tableView endUpdates];

As you can guess, this gives me weird results. For instance, the cell separator disappears. After switching back and forth between a few cells, the To Cell textField stops responding to touch.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top