From d3f62da37545681a04624ec63aa7aa43b0a63ed7 Mon Sep 17 00:00:00 2001 From: Peter <> Date: Thu, 1 Nov 2018 19:08:21 +0400 Subject: [PATCH] Additional fixes for global 3d touch workaround --- Display/NativeWindowHostView.swift | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Display/NativeWindowHostView.swift b/Display/NativeWindowHostView.swift index d3afd54b12..15dfe2c5eb 100644 --- a/Display/NativeWindowHostView.swift +++ b/Display/NativeWindowHostView.swift @@ -20,11 +20,9 @@ private func tracePreviewingHostView(view: UIView, point: CGPoint) -> (UIView & if let view = view as? UIView & PreviewingHostView { return (view, point) } - for subview in view.subviews { - if subview.frame.contains(point) && !subview.isHidden && subview.isUserInteractionEnabled { - if let result = tracePreviewingHostView(view: subview, point: view.convert(point, to: subview)) { - return result - } + if let superview = view.superview { + if let result = tracePreviewingHostView(view: superview, point: superview.convert(point, from: view)) { + return result } } return nil @@ -133,7 +131,10 @@ private final class WindowRootViewController: UIViewController, UIViewController public func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? { if #available(iOSApplicationExtension 9.0, *) { - if let (result, resultPoint) = tracePreviewingHostView(view: self.view, point: location), let delegate = result.previewingDelegate { + guard let result = self.view.hitTest(location, with: nil) else { + return nil + } + if let (result, resultPoint) = tracePreviewingHostView(view: result, point: self.view.convert(location, to: result)), let delegate = result.previewingDelegate { self.previousPreviewingHostView = result return delegate.previewingContext(previewingContext, viewControllerForLocation: resultPoint) }