Skip to content

Commit 329f036

Browse files
authored
Store window to local variable so GC doesn't collect it (#465)
1 parent 502cfe1 commit 329f036

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Core/src/Platform/iOS/MauiUIApplicationDelegate.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ namespace Microsoft.Maui
1111
{
1212
public class MauiUIApplicationDelegate<TApplication> : UIApplicationDelegate, IUIApplicationDelegate where TApplication : MauiApp
1313
{
14+
public override UIWindow? Window
15+
{
16+
get;
17+
set;
18+
}
19+
1420
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
1521
{
1622
if (!(Activator.CreateInstance(typeof(TApplication)) is TApplication app))
@@ -32,15 +38,15 @@ public override bool FinishedLaunching(UIApplication application, NSDictionary l
3238

3339
var content = (window.Page as IView) ?? window.Page.View;
3440

35-
var uiWindow = new UIWindow
41+
Window = new UIWindow
3642
{
3743
RootViewController = new UIViewController
3844
{
3945
View = content.ToNative(window.MauiContext)
4046
}
4147
};
4248

43-
uiWindow.MakeKeyAndVisible();
49+
Window.MakeKeyAndVisible();
4450

4551
return true;
4652
}

0 commit comments

Comments
 (0)