在我单击一个单元格以编辑一个对象后,该单元格会打开另一个 VC 以允许编辑,但如果用户单击取消,该单元格仍会被选中,并很快导致问题和崩溃。
单元格编辑:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"addAssignment"])
{
AddEditViewController *addEditController = segue.destinationViewController;
[addEditController setOtherdelegate:self];
}
if ([segue.identifier isEqualToString:@"edit"]) {
UITableViewCell *cell = sender;
AddEditViewController *addEditController = segue.destinationViewController;
[addEditController setOtherdelegate:self];
addEditController.edit = YES;
AssignmentInfo *a = [self.alist objectAtIndex:[self.tableView indexPathForCell:cell].row];
addEditController.assignmentEditing = a;
[self.alist removeObject:a];
[self.tableView reloadData];
NSString *filePath = [self dataFilePath];
[NSKeyedArchiver archiveRootObject:self.alist toFile:filePath];
}
}
按下取消按钮:
- (IBAction)addAssignmentCancelButtonPressed:(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];
}
如果需要,整个项目:http: //abdelelrafa.com/AssignmentAppTwo.zip