penatheboss penatheboss - 2 years ago 209
Swift Question

3d Touch Not Available on iPhone 6s+

I am trying to add 3d touch into my application. I am trying to enable the user to use force touch on a UITableViewCell, like shown in this project. I am running this code:

if traitCollection.forceTouchCapability == UIForceTouchCapability.Available {
registerForPreviewingWithDelegate(self, sourceView: view)
} else {

I have tried running it on an iPhone 6s+, but I receive "unavailable" in my logs. Why can I not use 3d touch on a 3d touch-supported device? Thanks for your help.

Answer Source

Just found some reference about 3D Touch APIs: according to the 3D Touch APIs documentation, Apple suggested that developers to read forceTouchCapability in traitCollectionDidChange: delegate method.

For example, you may check the value in your view controller using:

override func traitCollectionDidChange(previousTraitCollection: UITraitCollection?) {
    switch traitCollection.forceTouchCapability {
    case .Available:
    case .Unavailable:
    case .Unknown:

Hope it helps.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download