iosswift3dtouch

Peek and Pop for iPhone XR and iPhone XS


I want to add a peek and pop feature to my application. I managed to do it, but now I want to add support for iPhone 5s and iPhone Xr, in which there is no 3D Touch.

override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
    super.traitCollectionDidChange(previousTraitCollection)
    if traitCollection.forceTouchCapability == .available {
        registerForPreviewing(with: self, sourceView: messagesTableView)
    }
}

If I understand correctly, the only way is to implement it with long press.

  1. Can I force call peek for non 3D touch devices without implementing all action, blur, etc?
  2. Can I call native (default) peek and pop for non 3D touch devices when users long pressed? (haptic touch)

Solution

  • You can use PeekPop framework which provide backward compatibility for Peek and Pop.

    Haptic Touch can be generated via UIFeedbackGenerator subclasses.