iPhone – How to do full screen activity status

by: dermdaly

I’ve seen questions about how feed back to a user that something is pending, where you don’t want any input from the user. An example may be making an XML request for data from your iPhone app back to your server. While it is pending you want to show that your app is busy, but don’t want the user to interact with it.

The iPhone SDK has an activity indicator control that is used for such a purpose, but you may want to essentially make the fact that it is pending to be “modal”

Doing it is quite simple. Here’s how:

  1. Create a new view (this can be done in Interface builder) – Lets call it ProgressView. Make it full size, and stick an activity monitor in the middle of it.
  2. Set the view’s background to black, with its alpha set to 0.5. Create an outlet for the activity indicator in the ProgressView’s controller (call it myActivityIndicator)
  3. In the ProgressView’s controller, add the following code:
    - (void)viewDidLoad
    {
    [myActivityIndicator startAnimating];
    }

    - (void)viewWillDisappear: (BOOL)animated
    {
    [myActivityIndicator stopAnimating];
    }

  4. Now. Say we are going to do something that’s going to take some time in our main view controller. Just as we are starting it, we do this:
    [self.view addSubview:progressViewController.view];
  5. When we have completed our long running task, we do this:
    [progressViewController.view removeFromSuperview];

Voila – You have a nice progress indicator “modal dialog” (in old speak).

Of course, there are a number of ways of indicating progress, and you may not wish to disable interaction – Then you just use an activity indicator somewhere obvious in your UI.
Here’s how it looks in my app:

activity

Any other ideas? Please comment.

You May Also Like

App Store Optimization: Scaling Medical Apps

App Store Optimization: Scaling Medical Apps

Medical apps can be useful tools for helping users manage their health, appointments and medicine. Medical app developers have many things to take into consideration when launching their app, including: how will users find it? You can’t help anyone if your app isn’t...

read more
5 Sketch Plugins for UI/UX Designers

5 Sketch Plugins for UI/UX Designers

The best plugins are not only reliable but complement your workflow and enhance your designs. Here’s a quick list of some of our favourites that are useful not only for app designers, but anyone using Sketch as their main design tool.  Sketch Measure HTML Output from...

read more
Smartphone Trends Ireland 2020

Smartphone Trends Ireland 2020

19 out of 20 Irish adults own a smartphone. While ownership rates may be approaching a ceiling, the smartphone economy is just getting started and the smartphone industry is brimming with potential.Richard Howard, Partner, Technology, Media and Telecommunications,...

read more

12 Comments

  1. Avatar

    Hey it looks great! Perfect for synchs time in my app! Thanks for the help! Very useful!

    Reply
  2. Avatar

    Very very interesting post ..do you have a simple code …?? will be very usefulll…!!

    Ciao

    Reply
  3. Avatar

    very nice ..do you have a simple code …will be very usefull.. cia0

    Reply
  4. Avatar

    I am having trouble implementing this method with an app that I am developing. I have tried numerous times and various different ways to get a working activity indicator to appear over a webview in my application. The activity indicator is to show network activity in my app. Any chance you could email me and help me out a bit? I would greatly appreciate it!

    Reply
    • dermdaly

      Hi Endoze,
      Sure – Get in touch via mail and I’ll see if I can help.
      Cheers,
      Dermot.

      Reply
  5. Avatar

    Do you have an example project of this?

    I can’t seem to get it to work. I have a tabbarcontroller setup with 2 view controllers (for 2 tabs) under the tabbarcontroller. I’m not sure where I add the progressviewcontroller exactly.

    Thanks,
    Kim

    Reply
  6. Avatar

    Thanks for the tip on how to do this.

    However, the problem with this is that if you are loading data from an XML file that you acquire from online is that this screen won’t appear until after that file as loaded.

    You will need to start off a thread for the XML file download.

    Any tips for this?

    Reply
    • dermdaly

      Hi Bob,
      Surely, all you need to do is to start all of this prior to posting the XML request that obtains the file? I.e. Post XML, start activity indicator..When your data completes (and you delegate’s didFinishLoading gets called, you begin parsing the XML (e.g. using NSXMLParser).
      Then…when the parsing is complete (i.e. you Parser’s delegate’s parserDidEndDocument is called), then you stop the full screen animation.
      Does this make sense? If not, drop me a mail and I’ll see if I can help

      Reply
  7. Avatar

    Hi!
    Your tutorial is very useful, but i’m wondering if you can send me by mail the project sample. It is possible?

    Thanks in advance.

    Reply
  8. Avatar

    Hi, this is a great tip. I nearly understand how it works. My point is where I allocate the object progressViewController and where I release it, especially when I call the ProgressView inside a subview, not the main view.
    MAybe you could send me the example code or give me a hint.
    Thanks for the tip !
    Wolfgang

    Reply
  9. Avatar

    Perfect!

    Reply
  10. Avatar

    Hi,
    I am stuck.
    I have 2 Tabs in Tabbarcontroller, I fetch big Data in device(Local), so I need Activity indicator to run before all data display on the View, but no luck, I tried many way, but all the time my Indicator shows only after the data loaded. Could you help plz. Thanks

    Reply

Trackbacks/Pingbacks

  1. iPhone view won’t scale to fit iPad screen - Applerr.com All about Apple Products - Applerr.com All about Apple Products - [...] source for the activity indicator example i’ve used is at this link: https://tapadoo.wpengine.com/2009/iphone-how-to-do-full-screen-activity-status/ Via VN:F [1.9.8_1114]please wait...Rating: 0.0/10 (0…

Submit a Comment

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