Obtaining Row from DetailDisclosureButton (iPhone SDK)

Discussion in 'Mac Programming' started by Littleodie914, Apr 24, 2008.

  1. Littleodie914 macrumors 68000

    Littleodie914

    Joined:
    Jun 9, 2004
    Location:
    Rochester, NY
    #1
    Hey fellow MR developers, I'm trying to figure out how to determine which "row" a detailed disclosure button belongs to when it's clicked. I have the action set to a method, which is being called, but I don't know how to figure out the "indexPath," if you're familiar with other tableview code.

    Code:
    [cell setAccessoryType:UITableViewCellAccessoryDetailDisclosureButton];
    [cell setAccessoryAction:@selector(editSubject:)];
    [cell setTarget:self];
    Edit: I hate it how you can search everywhere, post a Q on here, then figure it out for yourself 5 minutes later. :)

    In case anyone else ever wonders, you use the UITableViewDelegate method:

    Code:
    - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
     
  2. iphoneGuy macrumors member

    Joined:
    Oct 26, 2007
    Location:
    [[NSLocation alloc] initWithCity: Chicago]
    #2
    Take a look at any of the samples they are great...

    Code:
    - (void)tableView:(UITableView *)tableView selectionDidChangeToIndexPath:(NSIndexPath *)newIndexPath fromIndexPath:(NSIndexPath *)oldIndexPath
    {
    	UIViewController *targetViewController = [[appController.dataFields objectAtIndex: newIndexPath.row] objectForKey:@"viewController"];
    	[[self navigationController] pushViewController:targetViewController animated:YES];
    }
    
     

Share This Page