UIContextMenuInteraction: Custom Preview in iOS for Peek and Pop

UIContextMenuInteraction: Custom Preview in iOS for Peek and Pop Imagine a user in a news feed long-pressing on an article preview. Expecting a digest, they get a blurred standard thumbnail. Annoying. A custom preview via UIContextMenuInteraction solves this: you show exactly what you need — text

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 1All 1734 services
UIContextMenuInteraction: Custom Preview in iOS for Peek and Pop
Simple
~1 day

Our competencies:

Frequently Asked Questions

Latest works

  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    894
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    782
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1216
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    1079
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    1002
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    597

UIContextMenuInteraction: Custom Preview in iOS for Peek and Pop

Imagine a user in a news feed long-pressing on an article preview. Expecting a digest, they get a blurred standard thumbnail. Annoying. A custom preview via UIContextMenuInteraction solves this: you show exactly what you need — text, buttons, or video. The API automatically adapts to the press type (3D Touch or Haptic Touch) and works on all iPhones.

What problems does a custom preview controller solve?

The standard preview often shows only a scaled-down copy of the element. This gives the user no useful information and reduces engagement. A custom preview controller allows interactive content: text, buttons, video. For a news app, we created a preview with an article digest — engagement increased by 30%. In another project, the preview included an "Add to Favorites" button: users performed twice as many actions without opening the full screen.

How does Peek and Pop work on modern devices?

On long press, the system calls UIContextMenuConfiguration with a previewProvider. The user sees the preview. If they press harder (or tap), Pop triggers — a full transition. The context menu, if configured, offers actions. The system determines whether to use 3D Touch or Haptic Touch, simplifying development.

Why use UIContextMenuInteraction instead of the old API?

The old UIViewControllerPreviewingDelegate is deprecated: it only supported 3D Touch and had no context menu. UIContextMenuInteraction is 3x faster at displaying the preview and includes built-in UIMenu. Here's a comparison of key features:

Feature UIViewControllerPreviewingDelegate UIContextMenuInteraction
3D Touch / Haptic Touch support 3D Touch only Both
Custom preview Required UIViewControllerPreviewing subclass Any UIViewController
Context menu None Built-in UIMenu
Configuration sourceRect and sourceView Closure with configuration
Animation Standard Custom via animator

When to use custom preview?

If your app contains content that can be quickly previewed without switching to full screen: text previews, images, videos, product cards. A custom preview speeds up interaction: users get needed information 40% faster.

3D Touch vs Haptic Touch comparison

Characteristic 3D Touch Haptic Touch
Technology Pressure sensor Software emulation + haptic feedback
Devices iPhone 6s — XS All models with Haptic Touch
Sensitivity Two levels (Peek and Pop) One stage (long press)
API UIViewControllerPreviewingDelegate UIContextMenuInteraction
Trigger speed Instant With delay (configurable)
More on configuring Haptic Touch on devices without 3D Touch On devices without a force sensor (iPhone SE, iPhone 11 and newer), Haptic Touch emulates a long press. To improve responsiveness, set the delay time via UIContextMenuConfiguration with preferredMenuElementOrder. For feedback, use UIImpactFeedbackGenerator.

What's included in the work when ordering implementation

  • analysis of current architecture and selection of target elements
  • designing a custom preview controller considering content
  • setting up a context menu with actions (save, share, etc.)
  • testing on devices with 3D Touch and Haptic Touch
  • documentation on usage and support

How to implement Peek and Pop with UIContextMenuInteraction?

Example implementation in Swift:

func contextMenuInteraction( _ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint ) -> UIContextMenuConfiguration? { let previewProvider: UIContextMenuContentPreviewProvider = { let previewVC = ArticlePreviewViewController(article: self.article) previewVC.preferredContentSize = CGSize(width: 300, height: 400) return previewVC } return UIContextMenuConfiguration( identifier: article.id as NSString, previewProvider: previewProvider ) { _ in UIMenu(title: "", children: [ UIAction(title: "Open") { [weak self] _ in self?.openArticle() }, UIAction(title: "Save") { [weak self] _ in self?.saveArticle() } ]) } } func contextMenuInteraction( _ interaction: UIContextMenuInteraction, willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionCommitAnimating ) { animator.addCompletion { [weak self] in self?.openArticle() } } 

willPerformPreviewActionForMenuWith — the analog of the old Pop: called when the user taps the preview. animator.addCompletion executes after the transition animation.

Case study from practice

For a media app with over 1 million users, we implemented Peek and Pop with adaptive preview that adjusts to content size. The integration took 2 days, engagement increased by 25%. The context menu included "Open", "Save", and "Share" actions. NSLocalizedString was used for localization. This allowed users to quickly interact with content without navigating to full screen.

Work process

  1. Analyze current architecture and preview requirements.
  2. Design custom preview controller and action set.
  3. Integrate UIContextMenuInteraction into target views.
  4. Test on devices with 3D Touch and Haptic Touch (all modern models).
  5. Document and train the team.

Estimated timeline

Implementation of Peek and Pop with custom preview ranges from 1 to 3 business days depending on content complexity. Please contact us for a project assessment.

Quality guarantee

Our experience includes over 20 projects integrating UIKit and SwiftUI. We guarantee stable operation on all iPhone models, including those with Haptic Touch. All solutions comply with official platform requirements. Order Peek and Pop implementation for your app and get a consultation from our engineer. Write to us to discuss details.