Reputation: 3317
It would be great to have library that both:
Advantages:
Anybody knows if that is possible or knows code - please share with us.
Upvotes: -3
Views: 994
Reputation: 92
This is what apple recommends:
To ensure that all your users can access your app’s features, branch your code depending on whether 3D Touch is available. When it is available, take advantage of 3D Touch capabilities. When it is not available, provide alternatives such as by employing touch and hold, implemented with the UILongPressGestureRecognizer class.
Upvotes: 0
Reputation: 4564
I have built a library to use as an alternative for devices without 3D Touch. My demo project also demonstrates how the project can support both types of devices. You can try it here: PeekView
The usage is pretty simple:
Sample snippet:
PeekView.viewForController(
parentViewController: self,
contentViewController: controller,
expectedContentViewFrame: frame,
fromGesture: gestureRecognizer,
shouldHideStatusBar: true,
withOptions: ["Option 1": .Destructive, "Option 2": .Default, "Option 3": .Selected],
completionHandler: { optionIndex in
switch optionIndex {
case 0:
print("Option 1 selected")
case 1:
print("Option 2 selected")
case 2:
print("Option 3 selected")
default:
break
}
})
Preview:
Upvotes: 1
Reputation: 3838
Here’s an open source project that provides a neat tweak for the iPhone simulator that allows you to simulate 3D touch within the iOS simulator called SBShortcutMenuSimulator.
SBShortcutMenuSimulator allows you to test usage of the UIApplicationShortcutItem API even without a device supporting 3D touch.
This screenshot from the readme shows a demonstration of an application shortcut menu in the simulator:
Upvotes: 0
Reputation: 36074
You could perhaps emulate the behaviour by looking at the UITouch
properties majorRadius
and majorRadiusTolerance
, available in iOS 8, which describe the approximate radius of the touch or "finger fatness".
This ought to be loosely correlated with pressure.
I'm not sure the properties change continuously / produce a stream of touchesMoved:
callbacks, but it might be a start.
Upvotes: 1