iosobjective-ciphonexcode3dtouch

How to check 3D touch available in iPhone programmatically?


I have my ios application I want to check how 3D touch available means (iPhone 6s or iPhone6s plus)?

so how can I check it?


Solution

  • 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];
    }