Hey everybody, I had a question about editing the value of a table cell and returning the edited value back to the original cell.
I have a UITableView which contains 5 sections of 1 row each. Within cellForRowAtIndexPath I have the following:
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
}
NSString *fieldTitle;
switch (indexPath.section)
{
case 0:
fieldTitle = @"First Name";
break;
case 1:
fieldTitle = @"Last Name";
break;
case 2:
fieldTitle = @"Company";
break;
case 3:
fieldTitle = @"Email Address";
break;
case 4:
fieldTitle = @"Password";
break;
}
cell.textLabel.text = fieldTitle;
When a row is clicked, didSelectRowAtIndexPath is fired as follows:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
AddField *addField = [[AddField alloc] initWithStyle:UITableViewStyleGrouped];
addField.field = cell.textLabel.text;
addField.title = cell.textLabel.text;
addField.value = cell.detailTextLabel.text;
[self.navigationController pushViewController:addField animated:YES];
}
This sets up another UITableView that contains one section and one row. This table utilizes a custom cell I wrote that contains a text field the user can edit. There is a done button the user can click to go back to the previous view.
My question is this: How do I get the value the user entered in the AddField view to appear in the detailText label on the selected table cell in the previous view? This functionality would be very similar to adding the title of a new event in the iPhone's native calendar application.
Thanks for any help I can get, and let me know if you need more information.