13

我正在尝试将单元格行为更改为:1)当单元格被点击时,将单元格标记为完整并带有复选标记 2)当点击详细信息披露附件按钮时,执行 Segue。3)在 tableView:didSelectRowAtIndexPath: 我有:

- (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__);
}

deselectRowAtIndexPath 应该绕过 segue,但事实并非如此。

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

请注意,“didSelect”出现在“prepareForSegue”之后。

任何提示将不胜感激。

4

3 回答 3

14

您是否已将详细信息附加到表格视图单元格?相反,尝试在两个视图控制器之间拖动它(一个包含表格,另一个是您希望它去的地方)。

然后手动执行 ( [self performSegueWithIdentifier:@"MySegue"];) 时tableView:accessoryButtonTappedForRowWithIndexPath:

于 2012-04-30T00:04:37.140 回答
6

如果需要在 prepareForSegue 中获取当前 tableview 选择,可以通过访问 UITableViewController 的 tableView ivar 来获取;

[self tableView] indexPathForSelectedRow]
于 2012-07-02T18:01:26.137 回答
1
- (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;

    }

}

故事板上的序列

于 2013-07-11T19:31:54.870 回答