From ac57aa61bf45d58ee654684bb3df32ed41e5253f Mon Sep 17 00:00:00 2001 From: Ali <> Date: Fri, 20 Dec 2019 20:26:09 +0400 Subject: [PATCH] Use window's root controller to present native controllers --- submodules/Display/Display/NativeWindowHostView.swift | 4 ++++ submodules/Display/Display/ViewController.swift | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/submodules/Display/Display/NativeWindowHostView.swift b/submodules/Display/Display/NativeWindowHostView.swift index 7529222a06..b408471db7 100644 --- a/submodules/Display/Display/NativeWindowHostView.swift +++ b/submodules/Display/Display/NativeWindowHostView.swift @@ -246,6 +246,10 @@ private final class WindowRootViewController: UIViewController, UIViewController self.previousPreviewingHostView = nil } } + + override public func present(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)? = nil) { + super.present(viewControllerToPresent, animated: flag, completion: completion) + } } private final class NativeWindow: UIWindow, WindowHost { diff --git a/submodules/Display/Display/ViewController.swift b/submodules/Display/Display/ViewController.swift index 454f764476..566c83a2d7 100644 --- a/submodules/Display/Display/ViewController.swift +++ b/submodules/Display/Display/ViewController.swift @@ -448,8 +448,7 @@ public enum ViewControllerNavigationPresentation { } override open func present(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)? = nil) { - super.present(viewControllerToPresent, animated: flag, completion: completion) - return + self.view.window?.rootViewController?.present(viewControllerToPresent, animated: flag, completion: completion) } override open func dismiss(animated flag: Bool, completion: (() -> Void)? = nil) {