Ios Xcode未在表单元格上使用NSMutableArray
我正在构建一个使用表单元格的iPhone应用程序。我将此代码设置为尝试从表中删除单元格,但它似乎不起作用,因为我没有使用NSMutableArray。当我刷卡时,我得到了删除按钮,但删除按钮没有任何作用。我的问题是,如果我没有在我的表单元格中使用NSMutableArray,那么可以使用这一行:Ios Xcode未在表单元格上使用NSMutableArray,ios,xcode,uitableview,cocoa-touch,cell,Ios,Xcode,Uitableview,Cocoa Touch,Cell,我正在构建一个使用表单元格的iPhone应用程序。我将此代码设置为尝试从表中删除单元格,但它似乎不起作用,因为我没有使用NSMutableArray。当我刷卡时,我得到了删除按钮,但删除按钮没有任何作用。我的问题是,如果我没有在我的表单元格中使用NSMutableArray,那么可以使用这一行:[self.dataArray removeObjectAtIndex:indexPath.row]工作 使用的代码 (BOOL)tableView:(UITableView *)tableView ca
[self.dataArray removeObjectAtIndex:indexPath.row]代码>工作
使用的代码
(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return YES; }
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
//remove the deleted object from your data source.
//If your data source is an NSMutableArray, do this
[self.dataArray removeObjectAtIndex:indexPath.row];
} }
以下是apple doc的表视图编程指南的链接。它有一个简单的委托方法,使用NSArray
,并有一个示例代码可用于删除和插入。上面显示的代码缺少执行删除操作的代理部分。看看清单7.3,这可能就是您想要的