Azhar Ali Azhar Ali - 3 months ago 6x
iOS Question

Xamarin iOS: how to keep the view active when the loading logo in on the screen

In my iOS project, the page has a list view which takes some time to load. I want to display the loading squiggly as shown here but it is disabling the whole page until it loads up. I want to let the user go back using the navigation button if they want to during the loading process.

The code I am using now is:

var bounds = UIScreen.MainScreen.Bounds;
loadPop = new LoadingOverlay (bounds);
View.Add (loadPop);
loadingOverlay.Hide ();

Is there any way I can let the user use navigation to switch pages while the page still displays the loading symbol and the data is still being loaded?


It´s very simple actually. You just need to add a view (with the spinner) on top of the list and hide it manually when data is loaded. If you still want to use that LoadingOverlay sample, modify the bounds argument:

var navigationBarHeight = 48; // not sure what´s the actual height. Google it!
var bounds = UIScreen.MainScreen.Bounds; 
loadPop = new LoadingOverlay (new CGRect(bounds.X, navigationBarHeight, bounds.Width, bounds.Height - navigationBarHeight);
View.Add (loadPop);

If you just need the spinner, you can also take some code from the link your provided:

activitySpinner = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge); // change color here
activitySpinner.Frame = new CGRect (
                centerX - (activitySpinner.Frame.Width / 2) ,
                centerY - activitySpinner.Frame.Height - 20 ,
activitySpinner.AutoresizingMask = UIViewAutoresizing.All;
AddSubview (activitySpinner);
activitySpinner.StartAnimating ();