【问题标题】:How to change iPhone UITableView delete button title while editing it如何在编辑时更改 iPhone UITableView 删除按钮标题
【发布时间】:2010-12-09 02:14:58
【问题描述】:

在将编辑设置为YES 后,当我尝试从UITableView 中删除一行时,我需要更改默认删除按钮的标题。

【问题讨论】:

  • 您知道我们不知道您在谈论什么语言/系统/框架/平台吗?
  • 你好!如果您可以添加有关您正在做什么的任何内容,那就太好了...
  • 好的,我已经更新了问题,抱歉!

标签: ios iphone uitableview


【解决方案1】:

对于那些已经实现方法“titleForDeleteConfirmationButtonForRowAtIndexPath”并且仍然看到相同的“删除”文本的人。

尝试输入方法从头开始自动完成,因为我复制了某人的,它有一点不同的旧符号并且没有被调用!

【讨论】:

    【解决方案2】:

    斯威夫特

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

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

    这会使按钮显示“擦除”,但你可以使用任何你想要的字符串。

    我更完整的答案是here

    【讨论】:

      【解决方案3】:

      斯威夫特 3

      略有不同_

      func tableView(_ tableView: UITableView, titleForDeleteConfirmationButtonForRowAt indexPath: IndexPath) -> String? {
          return "Erase"
      }
      

      【讨论】:

        【解决方案4】:

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

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

        【讨论】:

        • 谢谢,但我确实添加了该方法并返回 NSString 就像返回 @"Remove";什么也没发生,它显示默认标题“删除”
        • @Vladimir,是否可以更改删除按钮的背景?默认其显示的“删除”按钮带有白色背景。
        • @Hemang,不记得在标准 UI 中看到白色的“删除”按钮 - 我认为没有开放的 API
        • @Vladimir,对不起!那里有误会!删除按钮只有红色,但它查看的背景是白色的。按钮位于该视图的中心。它不是我的自定义视图或任何东西,我只是覆盖此方法- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath,当我在UITableView 中的任何单元格上滑动时,它会显示删除按钮。
        • @Vladimir,我要做的是清除该视图的背景!这样任何单元格上只会显示删除按钮。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-11-15
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多