Haw*_*lot 4 objective-c uitableview ios popviewcontrolleranimated
我有一个包含自定义行的父表视图,每个视图控制器都推送一个视图控制器,其中包含tableview一些可选择的选项,这些选项存储为父视图控制器的属性.我的代码:
- (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];
}
Run Code Online (Sandbox Code Playgroud)
工作正常,不幸的didSelectRowAtIndexPath是,直到我第二次点击单元格列表后才会调用该方法.当我这样做时,它将先前选择的第一行传递给父视图.忽略大量的NSLog,只是捕捉变量正在做什么.
将您的didDeselectRowAtIndexPath方法重命名为didSelectRowAtIndexPath
它是第二次调用,因为您选择另一个单元格并取消选择前一个单元格
| 归档时间: |
|
| 查看次数: |
735 次 |
| 最近记录: |