Reputation: 211
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.
Upvotes: 13
Views: 4044
Reputation: 62676
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:
.
Upvotes: 14
Reputation: 651
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Make sure your segue name in storyboard is the same as this line
if ([[segue identifier] isEqualToString:@"ClaimDetailsSeque"])
{
DLog(@"destinationViewController %@",[[segue destinationViewController] topViewController]);
//This syntax is needed when the seque is going through a Navagation Controller
ClaimDetailsFormViewController* vc = (ClaimDetailsFormViewController*)[[segue destinationViewController] topViewController];
//This the the way to get the object from the selected row via the FetchedResultsController
//this is needed because prepareForSegue is called before didSelectRowAtIndexPath
NSIndexPath *selectedIndexPath = [self->claimTableView indexPathForSelectedRow];
ClaimHistory *object = [[self claimHistoryFetchedResultsController] objectAtIndexPath:selectedIndexPath];
MyClaimHistorySM *myCH = [MyClaimHistorySM new];
myCH.policyNumber = object.policyNumber;
myCH.policyStatus = object.policyStatus;
myCH.claimNumber = object.claimNumber;
myCH.insuredName = object.insuredName;
myCH.lossDescription = object.lossDescription;
myCH.dateOfLoss = object.dateOfLoss;
myCH.incidentCloseDt = object.incidentCloseDt;
vc.claimHistorySM = myCH;
}
}
Upvotes: 1
Reputation: 411
If you need to get the current tableview selection in prepareForSegue you can get it by accessing the UITableViewController's tableView ivar;
[self tableView] indexPathForSelectedRow]
Upvotes: 6