From 4c1548b5b2f1a77f87fa6fbb35d5fc82984050dd Mon Sep 17 00:00:00 2001 From: Ieuan Walker Date: Tue, 17 Sep 2024 12:45:44 +0100 Subject: [PATCH 1/2] Update PopupWindow.cs --- .../Mopups.Maui/Platforms/iOS/PopupWindow.cs | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/Mopups/Mopups.Maui/Platforms/iOS/PopupWindow.cs b/Mopups/Mopups.Maui/Platforms/iOS/PopupWindow.cs index d5ddfa1..e91fda0 100644 --- a/Mopups/Mopups.Maui/Platforms/iOS/PopupWindow.cs +++ b/Mopups/Mopups.Maui/Platforms/iOS/PopupWindow.cs @@ -24,25 +24,36 @@ public PopupWindow(UIWindowScene uiWindowScene) : base(uiWindowScene) } - public override UIView HitTest(CGPoint point, UIEvent? uievent) + public override UIView? HitTest(CGPoint point, UIEvent? uievent) { - var platformHandler = (PopupPageRenderer?)RootViewController; - var renderer = platformHandler?.Handler; - var hitTestResult = base.HitTest(point, uievent); - - if (!(platformHandler?.Handler?.VirtualView is PopupPage formsElement)) + try + { + var platformHandler = (PopupPageRenderer?)RootViewController; + var renderer = platformHandler?.Handler; + var hitTestResult = base.HitTest(point, uievent); + + if(renderer?.VirtualView is null) + { + return hitTestResult; + } + + if(renderer.VirtualView is not PopupPage formsElement) + return hitTestResult; + + if(formsElement.InputTransparent) + return null; + + if(formsElement.BackgroundInputTransparent && renderer.PlatformView == hitTestResult) + { + formsElement.SendBackgroundClick(); + return null; + } return hitTestResult; - - if (formsElement.InputTransparent) - return null!; - - if (formsElement.BackgroundInputTransparent && renderer?.PlatformView == hitTestResult) + } + catch(Exception) { - formsElement.SendBackgroundClick(); - return null!; + return null; } - return hitTestResult; - } } } From bce14b7a4993c8aa5a7f975c64c7d01e4c7efdd9 Mon Sep 17 00:00:00 2001 From: Ieuan Walker Date: Tue, 17 Sep 2024 13:29:26 +0100 Subject: [PATCH 2/2] Update PopupWindow.cs --- Mopups/Mopups.Maui/Platforms/iOS/PopupWindow.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Mopups/Mopups.Maui/Platforms/iOS/PopupWindow.cs b/Mopups/Mopups.Maui/Platforms/iOS/PopupWindow.cs index e91fda0..e6ffc88 100644 --- a/Mopups/Mopups.Maui/Platforms/iOS/PopupWindow.cs +++ b/Mopups/Mopups.Maui/Platforms/iOS/PopupWindow.cs @@ -24,7 +24,7 @@ public PopupWindow(UIWindowScene uiWindowScene) : base(uiWindowScene) } - public override UIView? HitTest(CGPoint point, UIEvent? uievent) + public override UIView? HitTest(CGPoint point, UIEvent? uievent) { try { @@ -52,6 +52,12 @@ public PopupWindow(UIWindowScene uiWindowScene) : base(uiWindowScene) } catch(Exception) { + // Perform any necessary cleanup here + RootViewController?.View?.RemoveFromSuperview(); + RootViewController = null; + Hidden = true; + Dispose(); + return null; } }