客观的:
- 选择时添加一个自定义按钮,标题
Delete
为一行 并在单元格选择更改时将其删除,等等将“删除”添加到最后一个选择。
(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath{ self.myIndexPath=indexPath; UIButton *btnCustomDelete=[[UIButton alloc] initWithFrame:CGRectMake(260, 10, 60, 7)]; [btnCustomDelete setTitle:@"Delete" forState:UIControlStateNormal]; [tblCellForContactTable.contentView addSubview: btnCustomDelete]; //I think correction wants here [btnCustomDelete addTarget:self action:@selector(actionCustomDelete:) forControlEvents:UIControlEventTouchUpInside]; } -(IBAction) actionCustomDelete:(id)sender{ [arrForMyContacts removeObject:[arrForMyContacts objectAtIndex:myIndexPath.row]]; [tblForContacts reloadData]; }
但是,它并非一直有效。