iOS 9: How to Peek & Pop A Specific View Inside a UITableViewCell

Over the past few days, I’ve been hectically working on the try! Swift Conference app (now only 2.5 more weeks to show time 😱)! One of my stretch goal MVP features was implementing 3D Touch to Peek & Pop speaker and presentation information in the app. Luckily, @allonsykraken made it so easy with this Peek & Pop Spirit Guide, that it took only minutes to implement on the main table views in my app.


However, I got slightly stuck on the Q&A Session screen. I wanted specific views in the cell – the speaker images – to peek & pop, not the entire cell as in the other table views!


Since this took me slightly longer to figure out, I wanted to add a note on how I did it (make sure to read Peek & Pop Spirit Guide first!).

The Problem

To get the Peak & Pop to work, we need to conform to the UIViewControllerPreviewingDelegate protocol – this is what tells us the location of the view the user 3D Touched, and this is where we return the ViewController that should be Peeked & Popped.

Since my images are in the cell and I want to differentiate between which speaker image was 3D Touched, I configured my cell conform to the UIViewControllerPreviewingDelegate:

The problem is that in order for the Peek & Pop functionality to work, we need to register the view and delegate by calling registerForPreviewingWithDelegate, but registerForPreviewingWithDelegate is a method in the UIViewController, so we cannot register the views within the cell!

The Solution

The key here is that we now have to register every single cell in the view controller (vs the entire table view like on the Schedule or Speaker tab in the demo above!).


@davedelong pointed out that having a cell produce a view controller seems wrong. Which I totally agree with! But at the time of writing the code with a tight deadline, I couldn’t figure out a better solution. Luckily, @davedelong also pointed me to the better solution, one that allows me to keep my view controller code in the view controller!

This code could use some refactoring, but hopefully you get the general idea!

Here is the demo of what this looks like – notice that the image selected is no longer blurry while everything around it is!


So it’s really not that hard to get a super specific view to work with 3D Touch! And in general, 3D touch is super simple and fun to implement. I highly recommend adding this super simple, but fun and powerful interaction to your app!

Peek & Pop All The Things!

Enjoy the article? Join over 14,500+ Swift developers and enthusiasts who get my weekly updates.