Search code examples
iphoneios5

in iOS app, why does prepareForSegue occur before didSelectRowAtIndexPath


I'm trying to change the cell behavior to: 1) When Cell Tapped, Mark Cell as Complete with a check mark 2) When Detail Disclosure Accessory button is tapped, perform the Segue. 3) In tableView:didSelectRowAtIndexPath: I have:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    AWDelivery *delivery = [self.fetchedResultsController objectAtIndexPath:indexPath];
    [delivery toggleDelivered: delivery];
    [self configureCheckmarkForCell:cell withDelivery:delivery];
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (debugging) NSLog(@"[%s] [%d]", __PRETTY_FUNCTION__, __LINE__);
}

the deselectRowAtIndexPath is supposed to bypass the segue, but it's not.

NSLogs: a) at 2012-04-29 18:50:00.848 Delivery[3148:fb03] [-[DeliveryTVC prepareForSegue:sender:]] [168] b) at 2012-04-29 18:50:01.245 Delivery[3148:fb03] [-[DeliveryTVC tableView:didSelectRowAtIndexPath:]] [93]

note that 'didSelect' occurs after 'prepareForSegue'.

Any hints would be most appreciated.


Solution

  • Do you have your detail segue attached to the table view cell? Instead, try dragging it between the two view controllers (the one containing the table and the one where you want it to go).

    Then perform it manually ([self performSegueWithIdentifier:@"MySegue"];) when tableView:accessoryButtonTappedForRowWithIndexPath:.