Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions Xamarin.Forms.Platform.iOS/FormsApplicationDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ public class FormsApplicationDelegate : UIApplicationDelegate
Application _application;
bool _isSuspended;
UIWindow _window;
public override UIWindow Window
{
get
{
return _window;
}
set
{
_window = value;
}
}

protected FormsApplicationDelegate()
{
Expand All @@ -37,7 +48,8 @@ public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary
// prepare you apps window and views for display
// keep lightweight, anything long winded should be executed asynchronously on a secondary thread.
// application:didFinishLaunchingWithOptions
_window = new UIWindow(UIScreen.MainScreen.Bounds);
if (Window == null)
Window = new UIWindow(UIScreen.MainScreen.Bounds);

if (_application == null)
throw new InvalidOperationException("You MUST invoke LoadApplication () before calling base.FinishedLaunching ()");
Expand Down Expand Up @@ -156,20 +168,19 @@ void CheckForAppLink(NSUserActivity userActivity)
void SetMainPage()
{
UpdateMainPage();
_window.MakeKeyAndVisible();
Window.MakeKeyAndVisible();
}

void UpdateMainPage()
{
if (_application.MainPage == null)
return;

var platformRenderer = (PlatformRenderer)_window.RootViewController;

var platformRenderer = Window.RootViewController as PlatformRenderer;
if (platformRenderer != null)
((IDisposable)platformRenderer.Platform).Dispose();

_window.RootViewController = _application.MainPage.CreateViewController();
Window.RootViewController = _application.MainPage.CreateViewController();
}
}
}