How to Display an Activity Indicator with UIActivityIndicatorView

Dec 3, 2009   //   by Derek van Vliet   //   Development  //  3 Comments

We all wish that our apps could run without latency and pauses, but the reality is loading screens are needed from time to time. Today’s advent tip is how to display an activity indicator in your app like the one seen below. It’s great for soothing the savage, impatient user.


It can actually be done with just a few lines of code. First, we create and position the UIActivityIndicatorView by doing the following. It needs to be added to a view, so be sure to replace “myView” with your own view.

UIActivityIndicatorView *activityView = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge] autorelease];
[myView addSubview: activityView]; = CGPointMake(240,160);

So now the activity indicator is created and positioned but it isn’t visible yet. You can make it visible at any time by running the following one line:

[activityView startAnimating];

Finally, once you’ve finished loading the copious amounts of awesomesauce that fuel your app, you can make the activity indicator go away by running the following solitary line of code:

[activityView stopAnimating];


  • […] network activity indicator is like the UIActivityIndicatorView we previously discussed, only it sits on the status bar, it is smaller, and believe it or not, it […]

  • […] How to Open a URL in Safari 2. How to Show an Alert with UIAlertView 3. How to Display an Activity Indicator with UIActivityIndicatorView 4. Eliminating class dependencies on your app delegate 5. How to Load a UIImage From a URL 6. How […]

  • i have a view in that view i have four buttons when we click on any button activitor indicator have ton work r spinning… to do……….

Leave a comment

Our Games