如何以编程方式检查 iPhone 中可用的 3D 触控?

How to check 3D touch available in iPhone programmatically?

我有我的 ios 应用程序 我想检查 3D 触摸可用意味着什么(iPhone 6s 或 iPhone6s plus)?

那我怎么查看呢?

你应该试试这个。

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