Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Littleodie914

macrumors 68000
Original poster
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
 
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

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];
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.