Reputation: 579
Here is my code:
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:@"editInfo" sender:nil];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"editInfo"]) {
EditInfoViewController *vc = [segue destinationViewController];
NSInteger selectedIndex = [[self.tableView indexPathForSelectedRow] row];
NSLog(@"%d",selectedIndex);
[vc setSelectedIndex:selectedIndex];
}
else if ([[segue identifier] isEqualToString:@"sendMessage"]) {
...
}
}
The selectedIndex variable is always NSLogged as 0... Any suggestions? Thanks.
Upvotes: 1
Views: 205
Reputation: 4421
Tapping a UITableViewCell's accessoryButton doesn't select the row containing the accessoryButton.
When you call performSegueWithIdentifier
, you could pass indexPath
as the sender
, which you could then reference in prepareForSegue
.
Upvotes: 4