<p>I'm trying to display a loading icon while my iPhone app downloads a network resource, but I can't figure out how to make it show up correctly.</p>

<p>I searched around and found some details on the <code>UIActivityView</code> class, but the available example source code didn't work, and the documentation is kind of terse.</p>

<p>Could someone provide a simple example on how to use this class?</p>

Assuming you've got a view controller set up, and would like to add a
```
UIActivityIndicator
```
to it, here's how you could do it:
(assume you've got a member variable called
```
indicator
```
, which you can use later to clean up)
For your interface (.h file):
```
```
UIActivityIndicator *indicator;
```
```
For your implementation (.m file):
Start the Animation
```
```
CGRect b = self.view.bounds;
indicator = [[UIActivityIndicator alloc] initWithActivityIndicatorStyle: 
                                             UIActivityIndicatorStyleWhite];
//center the indicator in the view
indicator.frame = CGRectMake((b.size.width - 20) / 2, (b.size.height - 20) / 2, 20, 20); 
[self.view addSubview: indicator];
[indicator release];
[indicator startAnimating];
```
```
Stop the Animation
```
```
[indicator removeFromSuperview];
indicator = nil;
```
```