Objective c UITableViewCell删除上的签名
我试图使用苹果提供的“编辑”->(-->“删除”功能从我的UITableView中删除一行 我在这里激活了按钮:Objective c UITableViewCell删除上的签名,objective-c,ios,uitableview,Objective C,Ios,Uitableview,我试图使用苹果提供的“编辑”->(-->“删除”功能从我的UITableView中删除一行 我在这里激活了按钮: - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.rightBarButtonItem = self.editButtonItem; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPat
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
PositionCell *cell = (PositionCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[PositionCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
FSExAppDelegate *appDelegate = (FSExAppDelegate *)[[UIApplication sharedApplication] delegate];
Position *pos = [appDelegate.positions objectAtIndex:indexPath.row];
[cell setPosition:pos];
// Configure the cell.
return cell;
}
在此处创建的UITableViewCell:
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
PositionCell *cell = (PositionCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[PositionCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
FSExAppDelegate *appDelegate = (FSExAppDelegate *)[[UIApplication sharedApplication] delegate];
Position *pos = [appDelegate.positions objectAtIndex:indexPath.row];
[cell setPosition:pos];
// Configure the cell.
return cell;
}
然后就是苹果提供的代码:
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source.
[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.
}
}
当我执行删除操作时,我被困在:
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
使用“线程1:程序接收信号‘SIGABRT’”
我一直在这里搜寻问题,但似乎找不到关于这个问题的任何东西。有人能帮忙吗
DJ。我想你漏掉了:
[mutableArrayAsDataSource removeObjectAtIndex:[indexPath row]];
这可能发生在deleteRowsAtIndexPaths调用之前
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
请把这个换成下面的
[tableView deleteRowsAtIndexPaths:[urArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];