Skip to content

Commit

Permalink
Fix The specified child already has a parent. You must call removeVie…
Browse files Browse the repository at this point in the history
…w() on the child's parent first. #6
  • Loading branch information
microspaze committed Apr 2, 2024
1 parent d90f7e9 commit a64a99d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions RGPopup.Maui/Platforms/Android/Impl/PopupPlatformDroid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PopupPageHandlerDroid>();
DecorView?.AddView(pageHandler.PlatformView);
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public async Task RemoveAsync(PopupPage page)
{
popup.IsOpen = false;
page.Parent = null;
page.Handler?.DisconnectHandler();
}

await Task.Delay(5);
Expand Down
1 change: 1 addition & 0 deletions RGPopup.Maui/Platforms/iOS/Impl/PopupPlatformIos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a64a99d

Please sign in to comment.