iOS 触觉触控 API 可能性

iOS Haptic Touch API Possibilities

由于我们正在失去 3D Touch API 和 iOS 13,例如 UIViewControllerPreviewingUIContextMenuInteraction 似乎是替代品。

如果您想在 Haptic Touch 上放置菜单,UIContextMenuInteraction 非常适合。如果您想在识别 Haptic Touch 时做其他事情怎么办?

有这种事吗?或者 Haptic Touch 是否与 UILongPressGesture 相同?

阅读文档 UIContextMenuInteraction 继承自 UIInteraction。正在搜索所有子类:

  • UIContextMenuInteraction
  • UIDragInteraction
  • UIDropInteraction
  • UILargeContentViewerInteraction
  • UIPencilInteraction
  • UISpringLoadedInteraction
  • UITextInteraction

查看每个子类我认为最适合替换 UIViewControllerPreviewing 的是 UILargeContentViewerInteraction,因为 UILargeContentViewerInteractionDelegate 有一个方法 return 视图控制器。

UIViewControllerPreviewing

UIContextMenuInteraction

UIInteraction

UILargeContentViewerInteractionDelegate

UIContextMenuInteraction 是完全替代品。您不必张贴菜单;你可以放一个自定义预览。该预览是视图控制器视图的快照,您提供该视图控制器。然后用户可以点击预览来执行实际的视图控制器转换。所以这就是 peek-and-pop 与视图控制器的精确模拟。