Forum Xamarin.iOS


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

unable to access UIApplication.SharedApplication.KeyWindow during the launch of the app as keywindow

saisai Member ✭✭
edited January 2019 in Xamarin.iOS

When my app is launched i show the Storyboad with an image in it like a splash screen. Then i call LoadApplication(new App()) from FinishedLaunching() method in AppDelegate class. In my App.cs, I need to access UIApplication.SharedApplication.KeyWindow.RootViewController to show a progress bar. But Keywindow is null and hence there is crash.

public override bool FinishedLaunching(UIApplication app, NSDictionary options)

LoadApplication(new App());
UIWindow.Appearance.TintColor = new UIColor(red: 0.55f, green: 0.76f, blue: 0.29f, alpha: 1.0f);
return base.FinishedLaunching(app, options);

App.cs file:

public App(string ticketNumberNotifParam = null, int ticketID = 0)
DependencyService.Get().Show("Updating user token...");


public void Show(string title, string message = "Loading")
UIViewController controller =
hud = new MTMBProgressHUD(controller.View);

Here Keywindow is null. Any suggestions what I'm doing wrong?


  • ColeXColeX Member, Xamarin Team Xamurai

    Try to use UIApplication.SharedApplication.Delegate.GetWindow() instead of UIApplication.SharedApplication.KeyWindow.

  • Liêm_NguyễnLiêm_Nguyễn USMember ✭✭✭✭

    @ColeX said:
    Try to use UIApplication.SharedApplication.Delegate.GetWindow() instead of UIApplication.SharedApplication.KeyWindow.

    Im put your code in Xamarin.Forms in DependencyService iOS. And call DP from App.xaml.cs

    windows allway null????

Sign In or Register to comment.