Search code examples
iosswiftios-simulatoruistoryboardsegue3dtouch

3D Touch Peek turns the screen white


I am trying to add a 3D Touch Preview & Commit Segue to my app, but for some reason whenever I try to peek in the iOS Simulator the area behind the view controller being peeked turns completely white, whereas it is meant to be blurred. This happened even when I tried implementing 3D Touch programatically in another app.

In the app where I did it using storyboards, I selected the following options for the segue:

Segue Options

And I tried to do it programatically in another app by following these steps (I have the same bug in that app too):

  1. Call registerForPreviewing(with: self, sourceView: view) in viewDidLoad
  2. Implement UIViewControllerPreviewingDelegate as follows:
    1. In previewingContext(_:viewControllerForLocation:), fetch the correct indexPath, set the context's source rect to it, instantiate the detail navigation controller from the storyboard, and return it.
    2. In previewingContext(_:commit:), push (viewControllerToCommit as? UINavigationController)?.rootViewController onto the navigation stack.

I'm not entirely sure whether this bug is specific to the iOS Simulator, since I don't have a 3D Touch enabled iOS device, but are there any additional steps required to correctly implement peeking and popping?

Here is an example of the bug that I'm encountering:

3D Touch Peek Bug


Solution

  • I managed to test the apps on a 3D Touch capable iOS device, and I can confirm that Peek and Pop works perfectly on the device with both apps. I have hence come to the conclusion that this is a simulator-specific bug.

    Peek and Pop on iPhone