0

我正在尝试制作一个UITableViewCell显示deleteConfirmationButton(在编辑模式下),就像我单击编辑控件时发生的那样,但在我的情况下,当用户单击UITableCell时我想要它。

我已经将该属性设置AllowsSelectionDuringEditing为 YES 并且可以删除行,我只希望 deleteConfirmationButton 避免任何意外。

关于如何做到这一点的任何提示?

谢谢!!

4

1 回答 1

0

为此,您可能会使用 commitEditingStyleForRowAtIndexPath 函数,该函数在编辑期间选择或删除对象时调用。

- (BOOL)tableView:(UITableView *)tableView
 canEditRowAtIndexPath:(NSIndexPath *)indexPath
 {
return YES;
 }    

然后为确认做这样的事情:

- (void)tableView:(UITableView *)tableView
 commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
 forRowAtIndexPath:(NSIndexPath *)indexPath

{
//make a UIAlert and display confirmation, if yes then run the following code, if no then break

// remove the object
 [myItems removeObjectAtIndex:indexPath.row];

// refresh the table view to display your new data
 [tableView reloadData];
 }
于 2012-01-18T17:11:03.583 回答