我有一個父表視圖與自定義行,每個人推視圖控制器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