I find it frustrating to be staring at a screen, with nothing changing, nothing responding, being not sure if there is something happening behind the scenes, or if the app has crashed. It doesn’t take much effort to pop up an activity indicator to let the user know on the UI that the app is thinking.

Here’s my quick way of using the UIActivityIndicatorView.

In the @interface declaration, add these:

IBOutlet UIActivityIndicatorView *activityIndicator;
//Outside the declaration add this line
@property (nonatomic, retain) UIActivityIndicatorView *activityIndicator;
// & dont forget to synthesize at the top of your .m file:
@synthesize activityIndicator;

Now to kick off the activity indicator, I use this code snippet. Sure, its a little verbose, but this ensures that the indicator is in the centre of the screen no matter the orientation.

self.activityIndicator = [[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray] autorelease];
float xpos = 0.0;
float ypos = 0.0;
//Calculate the distances to place activity indicator.  Take off 20px for status bar
if([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown){
   xpos = 320.0/2;
   ypos = 460.0/2;
   xpos = 480.0/2;
   ypos = 300.0/2;
activityIndicator.frame = CGRectMake(xpos-15, ypos-15, 30, 30);
self.activityIndicator.hidesWhenStopped = YES;
[self.view setUserInteractionEnabled:FALSE];
//set the subview to your view or your navigation controller, depending on your context
//[self.view addSubview:activityIndicator];
[self.navigationController.view addSubview:activityIndicator];
[activityIndicator startAnimating];

This kicks it off and sets it spinning.
To stop and dismiss the spinner, all we need to do is this:

[activityindicator stopAnimating];
[activityindicator removeFromSuperview];
activityindicator =nil;