Monotouch iPhone – Showing activity to the end (or how to create an iPhone wait cursor)

One of AIS’s recent projects involved development of an iPhone application using MonoTouch. This application made significant use of web services, some of which could take 10’s of seconds to return (Yes, we were moving a lot of data for this particular application… there is just no easy way to deal with “historical data”).

Rather than just locking the UI for the duration of the activity, we wanted to display a user notification that something was actually happening in the background. In addition, we wanted to disable the UI so the user did not inadvertently believe they could tap anything.

Our goals:

1. Display a “long running operation” notification to the user

2. Lock the primary UI to prevent unwanted unexpected user interactions

3. The component must be reusable

To accomplish this feat of programming, we decided to use a UIAlertView with a UIActivityIndicatorView on it. We created the ActivityAlertView class to manage this for us. It allows you to use it in one of 2 ways:

  1. In a using statement. This will display the ActivityAlertView for the duration that the using statement is in scope:
  2. using(ActivityAlertView alert
              = new ActivityAlertView("Logging in, Please wait"))
    {
          //Code to do while ActivityAlertView is displayed to user
    }

  3. Normal instantiation
  4. ActivityAlertView alert = new ActivityAlertView;
    alert.Show("Logging in, Please wait");
    //Code to do while ActivityAlertView is displayed to user
    alert.Dismiss();

Here are a few screenshots of the attached demo project.

imageimageimage
(Click image to enlarge)

Download the sample project and source code from this link

5 thoughts on “Monotouch iPhone – Showing activity to the end (or how to create an iPhone wait cursor)

  1. Dirk

    Hello,

    i cannot open the tar.gz, is there a way to get the demo in a .zip file?

    Regards,
    Dirk

  2. ArmgaSys Post author

    Dirk,
    I’ll go bug the developer and see if he can’t provider a .ZIP version. As he is a a Mac guy, it may take some arm twisting…

  3. Johan

    Hi Dave

    I also cannot open the tar file – even on a mac. I think the file is corrupt.
    Would you mind mailing it to me?

  4. AIS User

    Yup, the tarball is corrupted.
    We are flogging the developer to go create another tarball so we can get it posted.

Leave a Reply

Your email address will not be published. Required fields are marked *