Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

3D touch not available for the device swift

I want to add a feature to my app that requires 3D touch, but it says forceTouchCapability is not available.
I tried it on three virtual devices (iPhone 14 – iPhone 14 Pro – iPhone 11) and it is same for all the devices and all are up to date.
This is my code:

class ViewController: UIViewController {
    override func viewDidLoad() {
        
    }
    
    override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
        switch traitCollection.forceTouchCapability {
        case .available:
            print("Available")
        case .unavailable:
            print("Unavailable")
        case .unknown:
            print("Unknown")
        @unknown default:
            print("dd")
        }
    }
}

I have also downloaded many projects from github, using the feature of 3D touch.
They also show the same error as my project.
What is wrong please?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

3D Touch was removed in the iPhone 11 series and none of the newer iPhones have it, so what you are seeing is correct – you are testing forceTouchCapability on devices which don’t support Force Touch.

If you want to see which iPhone models support 3D Touch, see Adjust how iPhone responds to your touch, scroll to the Adjust settings for touch-and-hold gestures section, then select iPhone with 3D Touch. As you can see, out of the iPhone supporting iOS 17, only iPhone XS and XS Max support 3D Touch.

Also see this article explaining that 3D Touch is unavailable in iPhones introduced after 2018.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading