Check If 3D Touch Is Supported and Enabled on the iOS9 Device

Check if 3D touch is supported and enabled on the iOS9 device

I was accidentally casting forceTouchCapability to a BOOL (using it as a return value to my method that was set to return a boolean). I needed to check if forceTouchCapability was equal to UIForceTouchCapabilityAvailable.

Instead of:

return [[MyView traitCollection] forceTouchCapability];

I need:

return [[MyView traitCollection] forceTouchCapability] == UIForceTouchCapabilityAvailable;

swift check if 3D Touch is possible

Try this swift code, self is referring to your UIViewController

func is3DTouchAvailable() -> Bool
{
return self.traitCollection.forceTouchCapability == UIForceTouchCapability.Available
}

How to check 3D touch available in iPhone programmatically?

You should try this.

//check if the device supports 3DTouch
if(self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable){
[self registerForPreviewingWithDelegate:self sourceView:self.view];
}else{
[[[UIAlertView alloc] initWithTitle:@"Error" message:@"3DTouch not available" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil] show];
}

How to work with 3D Touch in iOS 9? Does it trigger event when pressure changes?

From the iOS 9.1 Release Notes

On 3D Touch capable devices, touch pressure changes cause touchesMoved: to be called.

Apps should be prepared to receive touch move events with no change in the x/y coordinates.

This means that a touchesMoved: callback either indicates a continuous change in force or location or both!

Hopefully this information will one day make it into the UITouch documentation.

Testing 3D touch with iOS Simulator

you must develop on a device that supports 3D Touch. Simulator does not support 3D Touch,the documentation from apple, if you need the more information related to this topic, visit this link.

Update

The iOS simulator with Xcode 7.3 beta has an option to Use Trackpad Force for 3D Touch

How to enable Force Touch Pressure on iOS Simulator 9.1

Simulator does not support interaction with iOS Devices using 3D Touch prior to Xcode 7.3. The menu item that you are referencing relates only to Apple Watch devices.

Testing 3D touch with iOS Simulator

you must develop on a device that supports 3D Touch. Simulator does not support 3D Touch,the documentation from apple, if you need the more information related to this topic, visit this link.

Update

The iOS simulator with Xcode 7.3 beta has an option to Use Trackpad Force for 3D Touch

How to check if Haptic Engine (UIFeedbackGenerator) is supported

Based on Apple's UIFeedbackGenerator documentation, sounds like iOS does that for you.

Note that calling these methods does not play haptics directly.
Instead, it informs the system of the event. The system then
determines whether to play the haptics based on the device
, the
application’s state, the amount of battery power remaining, and other
factors.

For example, haptic feedback is currently played only:

On a device with a supported Taptic Engine (iPhone 7 and iPhone 7
Plus).

When the app is running in the foreground.

When the System Haptics setting is enabled.

Even if you don't need to worry about check whether the device can do haptic feedback, you still need to ensure it's called only with iOS 10 or greater, so you could accomplish that with this:

    if #available(iOS 10,*) {
// your haptic feedback method
}

Here's a quick summary of the various haptic feedback options available in iOS 10.



Related Topics



Leave a reply



Submit