Passing data back from detailViewController to Uitableview

Posted by jsetting32 on Stack Overflow See other posts from Stack Overflow or by jsetting32
Published on 2013-06-27T16:18:22Z Indexed on 2013/06/27 16:21 UTC
Read the original article Hit count: 299

I am currently at the issue where I have a UITableviewCell that needs to be updated.

When the user presses on the uitableviewcell - THERES ONLY 1!!, the user is pushed to a UITABLEVIEWCONTROLLER where the user is allowed to select 1 of multiple cells with their own titles.

I need to get the clicked tableviewcells title and pass the value back to the parentviewcontroller and update the 1 tableviewcell's name to the one the user clicked in the pushed uitableivewcontroller.

Here is a picture of the parent viewcontroller... Parent Controller

And heres the picture of the pushed viewcontroller.... Child Controller

I was told earlier yesterday that delegation would be needed but I am unsure what to do at this point :/.

Heres some code I use in the parent viewcontroller...

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    ProblemTypes *view = [[ProblemTypes alloc] init];
    [self.navigationController pushViewController:view animated:YES];

}

I am also NOT USING storyboards, just a few xibs.

Also heres the code for the pushedviewcontroller to pop to the parent viewcontroller when a cell is selected...

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    NSLog(@"Cell's text: %@",cell.textLabel.text);

    [self.navigationController popViewControllerAnimated:YES];
}

Thank you guys!

© Stack Overflow or respective owner

Related posts about uitableview

Related posts about uinavigationcontroller