안녕하세요. 감사합니다. 나는 사용자가 단면 뷰로 변경할 수있는 테이블 뷰를 가지고있다. 표준보기에서는 모두 잘되지만 사용자가 단면 뷰로 전환하면 (-commitEditingStyle :) 함수를 사용하여 행을 삭제하려고 할 때 충돌이 발생합니다. 이 기능에서 나는 무엇을 놓치고 있습니까? 섹션이 만들어지면 행을 어떻게 삭제해야합니까? (I 배열의 사전이다 wchich PLIST에서 내 테이블을로드 각 인덱스가있는 TableView의 행 되..)섹션을 사용할 때 uiTableView를 어떻게 편집 (즉, 행 삭제)합니까?
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([strTitle isEqualToString:@"sectionView"]) {
@try {
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source.
// NSMutableDictionary *book =[[NSMutableDictionary alloc]init];
NSMutableDictionary *mynewList = [[NSMutableDictionary alloc]init];
mynewList = [[self.TitleDis valueForKey:[[[self.TitleDis allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)] objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row];
NSMutableArray *sectionRow = [mynewList objectForKey:@"Dis"];
[sectionRow removeObjectAtIndex:indexPath.row];
[mynewList writeToFile:[self dataFilePath] atomically:YES];
//
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
} else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
}
}
@catch (NSException *exception) {
NSLog(@"hello error...%@",exception);
}
}
else {
/////////////////////// STANDARD VIEW
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source.
[distribArray removeObjectAtIndex:indexPath.row];
//
// NSMutableArray *contents = [[NSMutableArray alloc] init];
// [contents addObject:myMasterList];
// //[contents addObject:[NSArray arrayWithObjects:arraydata.text,distroName.text,destorEmail.text, nil]];
[distribArray writeToFile:[self dataFilePath] atomically:YES];
//
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
} else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
}
//////////////////////////////////
}
}
콘솔 - [__ NSCFString removeObjectAtIndex :] : 미정 선택기 인스턴스 0xe4bd3f0 전송
당신이 볼 수 있듯이 나는 형식을 가지고 놀고있다 .... 다음에 무엇을 시도 해야할지 모르겠다 ??? 감사.
내가 단면 무엇을 의미 : 당신이 다음 mynewList을 allocing하고 어디
NSMutableDictionary *mynewList = [[NSMutableDictionary alloc]init];
mynewList = [[self.TitleDis valueForKey:[[[self.TitleDis allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)] objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row];
즉시 덮어 쓰기 : 이
'단면보기'란 무엇을 의미합니까? 테이블 뷰의 그룹 스타일을 의미합니까? – Tobi