Custom edit view in UITableViewCell while swipe left. Objective-C or Swift
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
On iOS, the standard way to show actions when a user swipes left on a UITableViewCell is to provide trailing swipe actions through the table view delegate. UIKit supports custom action titles, colors, and images, but it does not let you drop in a fully arbitrary edit view through the built-in API. If you need a truly custom panel, you usually have to build your own swipe interaction.
Use the Built-In Swipe Action API First
For iOS 11 and later, the recommended API is UIContextualAction with UISwipeActionsConfiguration. This covers most real app needs such as Edit, Delete, Archive, or Flag.
Swift example:
That gives you a polished native interaction with minimal code and correct table-view behavior.
Objective-C Version
The same pattern works in Objective-C:
If your goal is a branded action area with icons and custom colors, this is usually enough.
When “Custom Edit View” Means a Real Custom Panel
Many developers actually want more than action buttons. They want a fully custom view with labels, toggles, or a mini form that appears as the cell is swiped. The built-in swipe API is not designed for that.
If you need that level of control, the usual approach is:
- create a custom cell subclass
- place the main content view above a hidden action container
- add a pan gesture or use scroll mechanics
- animate the content view horizontally to reveal the custom container
A simplified Swift sketch:
This gives you freedom, but it also means you now own gesture conflicts, reuse behavior, accessibility, and closing previously opened cells.
Choosing the Right Approach
Use built-in swipe actions when:
- you need standard actions such as edit or delete
- buttons with text, color, and image are enough
- you want native behavior and less maintenance
Build a custom swipeable view only when:
- the built-in action buttons cannot express the UI
- you are prepared to manage gesture and reuse complexity
- the interaction is central enough to justify custom code
Common Pitfalls
The biggest pitfall is trying to force UISwipeActionsConfiguration to host arbitrary subviews. It is meant for action buttons, not for embedding a free-form edit panel.
Another common problem is state leakage during cell reuse. If one cell is half-swiped and reused for another row, the UI can appear broken unless you reset state in prepareForReuse.
Gesture conflicts are also easy to create. Custom pan handling can interfere with table scrolling, reorder gestures, or system edge swipes if it is not carefully implemented.
Finally, remember accessibility. A flashy swipe interaction is not enough if VoiceOver users cannot discover or trigger the same actions through accessible controls.
Summary
- For most apps, use
UIContextualActionandUISwipeActionsConfiguration. - UIKit supports custom button-style swipe actions, not arbitrary embedded edit views.
- If you need a real custom panel, build a custom cell and manage the swipe behavior yourself.
- Custom swipe UIs require careful handling of reuse, gestures, and accessibility.
- Start with the native API and only go custom when the built-in model is clearly insufficient.

