How to change iPhone UITableView delete button title while editing it

前端 未结 4 1496
礼貌的吻别
礼貌的吻别 2020-12-09 15:02

I need to change the title of the default delete button that appears when I attempt to delete a row from a UITableView after setting editing to YES

4条回答
  •  醉梦人生
    2020-12-09 15:45

    Swift

    Add this method to your UITableView delegate (probably your view controller).

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

    This makes the button say "Erase" but you can use any string you want.

    My fuller answer is here.

提交回复
热议问题