iOS development
UITableView customization
Swift programming
mobile app development
iOS UI design

How to change uitableview delete button text

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

Changing the delete button text in a UITableView depends on which swipe-action API you are using. In older table view editing code, the delegate method titleForDeleteConfirmationButtonForRowAt was the answer. In modern iOS code, the preferred approach is to define a custom UIContextualAction inside trailingSwipeActionsConfigurationForRowAt.

Legacy Approach: Delete Confirmation Title

Older UITableView editing APIs allow you to replace the default “Delete” text directly.

swift
1import UIKit
2
3class ViewController: UITableViewController {
4    let items = ["One", "Two", "Three"]
5
6    override func tableView(_ tableView: UITableView,
7                            titleForDeleteConfirmationButtonForRowAt indexPath: IndexPath) -> String? {
8        return "Remove"
9    }
10}

This works in legacy edit-confirmation flows where the system shows a delete confirmation button after swiping.

However, if you are building new code, this is no longer the API most teams should reach for first.

Modern Approach: UIContextualAction

For iOS 11 and later style swipe actions, define the action yourself.

swift
1import UIKit
2
3class ViewController: UITableViewController {
4    var items = ["One", "Two", "Three"]
5
6    override func tableView(_ tableView: UITableView,
7                            trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath)
8    -> UISwipeActionsConfiguration? {
9
10        let removeAction = UIContextualAction(style: .destructive, title: "Remove") {
11            [weak self] _, _, completion in
12            guard let self = self else {
13                completion(false)
14                return
15            }
16
17            self.items.remove(at: indexPath.row)
18            tableView.deleteRows(at: [indexPath], with: .automatic)
19            completion(true)
20        }
21
22        return UISwipeActionsConfiguration(actions: [removeAction])
23    }
24}

This gives you direct control over the label, style, icon, and behavior.

Why the Modern API Is Better

With UIContextualAction, you are not just renaming “Delete.” You are defining the entire swipe interaction. That means you can:

  • use custom text such as “Archive” or “Remove”
  • set a background color
  • attach an image
  • choose whether the action is destructive or normal

Example with color and icon:

swift
removeAction.backgroundColor = .systemRed
removeAction.image = UIImage(systemName: "trash")

This is far more flexible than the old delete-confirmation title hook.

Keep the Action Name Honest

Do not rename destructive behavior casually. If the action permanently deletes data, the label should communicate that clearly. “Remove” may be appropriate for removing from a list while preserving the underlying item. “Delete” is better if the record is actually destroyed.

Changing button text is a UI customization, but it also changes user expectations. Treat it as a product decision, not just a styling tweak.

Localization

If your app supports multiple languages, localize the action title.

swift
1let title = NSLocalizedString("Remove", comment: "Swipe action title")
2let removeAction = UIContextualAction(style: .destructive, title: title) { _, _, completion in
3    completion(true)
4}

This is easy to forget because swipe action titles are short, but they are still user-facing text.

Editing Style Still Matters in Legacy Code

If you are using the older commit editingStyle flow, remember that title customization alone does not implement the deletion behavior.

swift
1override func tableView(_ tableView: UITableView,
2                        commit editingStyle: UITableViewCell.EditingStyle,
3                        forRowAt indexPath: IndexPath) {
4    if editingStyle == .delete {
5        items.remove(at: indexPath.row)
6        tableView.deleteRows(at: [indexPath], with: .automatic)
7    }
8}

The title controls the button label. The commit method controls what actually happens.

Testing the Swipe UX

After changing the text, test:

  • long labels that may truncate
  • localization lengths
  • destructive color semantics
  • VoiceOver announcements

Swipe actions are compact UI elements, so wording and accessibility matter more than they first appear to.

Common Pitfalls

The main mistake is using the legacy title method in a codebase that already relies on modern swipe actions. Another is renaming a destructive action to something softer and thereby making the behavior ambiguous. Developers also sometimes forget that changing the title does not change the underlying delete logic. Finally, swipe action text should be localized and kept short enough to fit comfortably on smaller devices.

Summary

  • In legacy UITableView editing, use titleForDeleteConfirmationButtonForRowAt.
  • In modern iOS code, use UIContextualAction inside trailingSwipeActionsConfigurationForRowAt.
  • Choose button text that accurately reflects the action’s effect.
  • Localize the title for multi-language apps.
  • Test the resulting swipe interaction for truncation, accessibility, and behavior clarity.

Course illustration
Course illustration

All Rights Reserved.