/// <summary> /// Called automatically in ViewDidLoad() /// </summary> protected void StartLoadingScreen(string message) { using (var pool = new NSAutoreleasePool()) { this.InvokeOnMainThread(delegate { var bounds = new RectangleF(0, 0, 768, 1004); if (this.InterfaceOrientation == UIInterfaceOrientation.LandscapeLeft || this.InterfaceOrientation == UIInterfaceOrientation.LandscapeRight) { bounds = new RectangleF(0, 0, 1024, 748); } if (AppDelegate.IsPhone) { bounds = new RectangleF(0, 0, 320, 460); } this.loadingDialogView = new LoadingDialogView(message, bounds); // because DialogViewController is a UITableViewController, // we need to step OVER the UITableView, otherwise the loadingOverlay // sits *in* the scrolling area of the table this.View.Superview.Add(this.loadingDialogView); this.View.Superview.BringSubviewToFront(this.loadingDialogView); this.View.UserInteractionEnabled = false; }); } }
/// <summary> /// If a loading screen exists, it will fade it out. /// Your subclass MUST call this method once data has loaded (or a loading error occurred) /// to make the loading screen disappear and return control to the user /// </summary> protected void StopLoadingScreen() { using (var pool = new NSAutoreleasePool()) { this.InvokeOnMainThread(delegate { if (this.loadingDialogView != null) { Debug.WriteLine("Fade out loading..."); this.loadingDialogView.OnFinishedFadeOutAndRemove += delegate { if (this.loadingDialogView != null) { Debug.WriteLine("Disposing of loadingDialogView object.."); this.loadingDialogView.Dispose(); this.loadingDialogView = null; } }; this.loadingDialogView.FadeOutAndRemove(); this.View.UserInteractionEnabled = true; } }); } }