由于我们在 iOS 13 中失去了 3D Touch API,例如 UIViewControllerPreviewing
,UIContextMenuInteraction
似乎是替代品。
如果您想在 Haptic Touch 上放置菜单,UIContextMenuInteraction 非常适合。如果您想在识别 Haptic Touch 时做其他事情怎么办?
有这样的事吗?或者 Haptic Touch 是否与 UILongPressGesture
相同?
最佳答案
阅读文档 UIContextMenuInteraction 继承自 UIInteraction。搜索所有子类:
- UIContextMenuInteraction
- UIDragInteraction
- UIDropInteraction
- UILargeContentViewerInteraction
- UIPencilInteraction
- UISpringLoadedInteraction
- UITextInteraction
回顾每个子类,我认为最适合替换 UIViewControllerPreviewing 的是 UILargeContentViewerInteraction,因为 UILargeContentViewerInteractionDelegate 有一个返回 View Controller 的方法。
关于iOS 触觉触摸 API 的可能性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57697352/