diff --git a/RGPopup.Maui/Platforms/Android/Impl/PopupPlatformDroid.cs b/RGPopup.Maui/Platforms/Android/Impl/PopupPlatformDroid.cs index 96a65e9..33c1bc5 100644 --- a/RGPopup.Maui/Platforms/Android/Impl/PopupPlatformDroid.cs +++ b/RGPopup.Maui/Platforms/Android/Impl/PopupPlatformDroid.cs @@ -35,7 +35,7 @@ public event EventHandler OnInitialized public Task AddAsync(PopupPage page) { HandleAccessibilityWorkaround(page, ImportantForAccessibility.NoHideDescendants); - + page.Parent = XApplication.Current?.MainPage; var pageHandler = page.GetOrCreateHandler(); DecorView?.AddView(pageHandler.PlatformView); @@ -56,7 +56,8 @@ public Task RemoveAsync(PopupPage page) page.Parent = null; //If manual dispose the view's renderer, but the view is not disposed at the same time, it will crash when repush the view. //renderer.Dispose(); - + page.Handler?.DisconnectHandler(); + if (DecorView != null) return PostAsync(DecorView); } diff --git a/RGPopup.Maui/Platforms/MacCatalyst/Impl/PopupPlatformMacOS.cs b/RGPopup.Maui/Platforms/MacCatalyst/Impl/PopupPlatformMacOS.cs index 19df6af..550079b 100644 --- a/RGPopup.Maui/Platforms/MacCatalyst/Impl/PopupPlatformMacOS.cs +++ b/RGPopup.Maui/Platforms/MacCatalyst/Impl/PopupPlatformMacOS.cs @@ -89,6 +89,7 @@ public async Task RemoveAsync(PopupPage page) { var window = viewController.View?.Window; page.Parent = null; + page.Handler?.DisconnectHandler(); if (window != null) { var rvc = window.RootViewController; diff --git a/RGPopup.Maui/Platforms/Windows/Impl/PopupPlatformWindows.cs b/RGPopup.Maui/Platforms/Windows/Impl/PopupPlatformWindows.cs index 136c3b4..97c7558 100644 --- a/RGPopup.Maui/Platforms/Windows/Impl/PopupPlatformWindows.cs +++ b/RGPopup.Maui/Platforms/Windows/Impl/PopupPlatformWindows.cs @@ -65,6 +65,7 @@ public async Task RemoveAsync(PopupPage page) { popup.IsOpen = false; page.Parent = null; + page.Handler?.DisconnectHandler(); } await Task.Delay(5); diff --git a/RGPopup.Maui/Platforms/iOS/Impl/PopupPlatformIos.cs b/RGPopup.Maui/Platforms/iOS/Impl/PopupPlatformIos.cs index d0062ca..92dea35 100644 --- a/RGPopup.Maui/Platforms/iOS/Impl/PopupPlatformIos.cs +++ b/RGPopup.Maui/Platforms/iOS/Impl/PopupPlatformIos.cs @@ -86,6 +86,7 @@ public async Task RemoveAsync(PopupPage page) { var window = viewController.View?.Window; page.Parent = null; + page.Handler?.DisconnectHandler(); if (window != null) { var rvc = window.RootViewController;