Context Menu Implementation for iOS App

NOVASOLUTIONS.TECHNOLOGY is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
Context Menu Implementation for iOS App
Simple
~1 business day
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    756
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1052
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    862
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

Implementing Context Menu for iOS App

Context Menu in iOS 13+ is UIMenu + UIContextMenuInteraction. Correctly implemented context menu works identically on long press on Haptic Touch devices, on press with force on 3D Touch devices, and on right click on iPad with trackpad or Magic Mouse.

UIContextMenuInteraction for Arbitrary View

class CardView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        let interaction = UIContextMenuInteraction(delegate: self)
        addInteraction(interaction)
    }
}

extension CardView: UIContextMenuInteractionDelegate {

    func contextMenuInteraction(
        _ interaction: UIContextMenuInteraction,
        configurationForMenuAtLocation location: CGPoint
    ) -> UIContextMenuConfiguration? {
        UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { [weak self] _ in
            guard let self = self else { return nil }

            let open = UIAction(title: "Open", image: UIImage(systemName: "arrow.up.right")) { _ in
                self.handleOpen()
            }
            let copy = UIAction(title: "Copy", image: UIImage(systemName: "doc.on.doc")) { _ in
                self.handleCopy()
            }
            let delete = UIAction(
                title: "Delete",
                image: UIImage(systemName: "trash"),
                attributes: .destructive
            ) { _ in
                self.handleDelete()
            }

            // Grouping via UIMenu
            let editMenu = UIMenu(title: "", options: .displayInline, children: [copy])
            return UIMenu(title: "", children: [open, editMenu, delete])
        }
    }
}

options: .displayInline for nested UIMenu removes the subgroup title and visually separates items with a horizontal line — standard pattern for separating destructive actions from safe ones.

SwiftUI .contextMenu

struct ItemView: View {
    var item: Item

    var body: some View {
        ItemCard(item: item)
            .contextMenu {
                Button {
                    openItem(item)
                } label: {
                    Label("Open", systemImage: "arrow.up.right")
                }
                Button(role: .destructive) {
                    deleteItem(item)
                } label: {
                    Label("Delete", systemImage: "trash")
                }
            } preview: {
                ItemPreviewView(item: item)
                    .frame(width: 300, height: 200)
            }
    }
}

preview: in SwiftUI — preview on long press, analog of previewProvider in UIKit. Button(role: .destructive) automatically colors item red.

UITableView and UICollectionView

Specialized delegate methods without needing to add UIContextMenuInteraction manually:

// UITableView
func tableView(_ tableView: UITableView,
               contextMenuConfigurationForRowAt indexPath: IndexPath,
               point: CGPoint) -> UIContextMenuConfiguration? {
    // ...
}

// UICollectionView
func collectionView(_ collectionView: UICollectionView,
                    contextMenuConfigurationForItemsAt indexPaths: [IndexPath],
                    point: CGPoint) -> UIContextMenuConfiguration? {
    // iOS 16+ supports multiple selection
}

Timeline Benchmarks

Context menu for one View type or cell — a few hours. Full implementation for UITableView/UICollectionView with preview and custom actions — 1 working day.