I have embedded textfields in cells and I have an edit button that is supposed to trigger a cell into an edit mode where I can edit the text in the cell.
What I need to do is loop through all the textfields and set the userInteractionEnabledto yes. I have done this here in the `setEditing:animated method:
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
[super setEditing:editing animated:animated];
if (editing)
{
int tagNumber = 0;
for (id cellTextField in [tableView visibleCells]) {
UITextField *aField = (UITextField *)[cellTextField viewWithTag:tagNumber];
aField.userInteractionEnabled = YES;
tagNumber++;
}
self.editButtonItem.title = NSLocalizedString(@"Done", @"Done");
}
else
{
self.editButtonItem.title = NSLocalizedString(@"Delete", @"Delete");
}
}
Then I need to somehow put all of those textFields back into the tableview cells. Hope someone can help.
Cheers.
Realised I was being a bit stupid when I forgot the whole point of pointers.
In the cellForRowAtIndexPath method, I added the UITextFields to an array (after adding them as subviews to the cells). Then in the edit button method, I just used fast enumeration to cycle through the array of textFields and changed the userInteractionEnabled property from there.
Here is the code for creating the textfields:
Here is the code for making them editable: