2012-01-17 29 views
0

我试图使UITableViewCell显示deleteConfirmationButton(处于编辑模式时),就像在单击编辑控件时发生的情况一样,但在我的情况下,当用户单击时我需要它通过UITableCell。如何在单击的UITableViewCell上显示deleteConfirmationButton

我已经设置属性AllowsSelectionDuringEditing为YES,我可以删除行,我只想deleteConfirmationButton避免任何意外。

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

谢谢!

回答

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]; 
} 
+0

那不是我一直在寻找,但我认为它应该解决的问题。 – jMelnik 2012-01-20 12:52:23

相关问题