0

所以关于 rightBarButtonItem 。我有

self.navigationItem.rightBarButtonItem = self.editButtonItem;

当我按下 Edit 时,我会在每个 TableViewCell 的左侧看到动画和垂直条纹。当我单击那个条带时,删除按钮出现在那个 tableViewCell 的右侧。

我想做两件事。

  1. 将“删除”重命名为“检查”
  2. 如果它被选中,它应该显示“取消选中”以被点击。

我将不胜感激。

:)

4

2 回答 2

3

tableView:titleForDeleteConfirmationButtonForRowAtIndexPath:在您的表视图委托中实现。

于 2011-06-02T19:33:39.890 回答
1

对于答案的第二部分,我这样做了。

if (editingStyle == UITableViewCellEditingStyleDelete) {

 UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];

 if (selectedCell.accessoryType == UITableViewCellAccessoryNone)
 {
     selectedCell.accessoryType = UITableViewCellAccessoryCheckmark;
 }
 else 
     if (selectedCell.accessoryType == UITableViewCellAccessoryCheckmark)
     {
         selectedCell.accessoryType = UITableViewCellAccessoryNone;
     }

}   

- (NSString *) tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{

UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];

if (selectedCell.accessoryType == UITableViewCellAccessoryNone)
{

    return (@"Check");
}
else 
    if (selectedCell.accessoryType == UITableViewCellAccessoryCheckmark)
    {

        return (@"UnCheck");
    }

}
于 2011-06-02T20:01:00.133 回答