我正在尝试将细胞行为更改为: 1)当单元格点击时,将单元格标记为完成,并带有复选标记 2)轻触Detail Disclosure Accessory按钮时,执行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交货[3148:fb03] [ - [DeliveryTVC prepareForSegue:sender:]] [168] b)在2012-04-29 18:50:01.245交货[3148:fb03] [ - [DeliveryTVC tableView:didSelectRowAtIndexPath:]] [93]
请注意'didSelect'出现在'prepareForSegue'之后。
任何提示都将非常受欢迎。
答案 0 :(得分:14)
您是否将详细信息列表附加到表格视图单元格?相反,尝试在两个视图控制器之间拖动它(包含表格的那个和你想要它去的那个)。
然后在[self performSegueWithIdentifier:@"MySegue"];
时手动执行(tableView:accessoryButtonTappedForRowWithIndexPath:
)。
答案 1 :(得分:6)
如果您需要在prepareForSegue中获取当前的tableview选项,可以通过访问UITableViewController的tableView ivar来获取它;
[self tableView] indexPathForSelectedRow]
答案 2 :(得分: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;
}
}