如何在编辑时更改iPhone UITableView删除按钮标题

Min*_*ael 31 iphone uitableview ios

我需要更改当我尝试从UITableView后设置编辑中删除行时出现的默认删除按钮的标题YES.

Vla*_*mir 89

您可以在UITableView委托方法中更改它

- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)

  • @Hemang它可能值得作为一个单独的问题提出 (4认同)

Sur*_*gch 6

迅速

将此方法添加到您的UITableView委托(可能是您的视图控制器)中。

func tableView(_ tableView: UITableView, titleForDeleteConfirmationButtonForRowAtIndexPath indexPath: NSIndexPath) -> String? {
    return "Erase"
}
Run Code Online (Sandbox Code Playgroud)

这会使按钮说“ Erase”(擦除),但是您可以使用所需的任何字符串。

在此处输入图片说明

我的完整答案在这里