我有一个父表视图与自定义行,每个人推视图控制器tableview
的可选选项,作为父视图控制器的属性存储。我的代码:为什么我的tableview不会调用didselectrowatindexpath直到第二次触摸?
- (void) tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
/*
CrewPositions *selectedPosition = (self.crewPositionList)[indexPath.row];
[self.delegate childCrewPositionDidSelect:selectedPosition];
NSLog(@"child Selected Position: %@", selectedPosition.title);
[[self navigationController] popViewControllerAnimated:YES];
*/
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.accessoryType = UITableViewCellAccessoryCheckmark;
CrewPositions *selectedPosition = (self.crewPositionList)[indexPath.row];
self.selectedCrewPosition = selectedPosition;
NSLog(@"self.selectedCrewPosition: %@", self.selectedCrewPosition);
selectedFlightHistory.crewPosition = selectedPosition;
NSLog(@"self.selectedFlightHistory.crewPosition: %@", selectedFlightHistory.crewPosition.title);
[self.delegate childCrewPositionDidSelect:selectedPosition];
NSLog(@"Popping view to parent");
[self.navigationController popViewControllerAnimated:YES];
}
正常工作,遗憾的是该方法didSelectRowAtIndexPath
不会被调用,直到后,我拼接单元的列表中的第二次。当我这样做时,它将先前选择的第一行传递给父视图。忽略大量的NSLog
,只是捕获变量正在做的事情。
是的 - 如果您阅读正在实施的委托方法的名称,它会有所帮助。 – Abizern