03-17-2012, 04:48 PM
I would first create an IBOutlet variable for the UIActivityIndicatorView class, in the header
file for your controller class, and add the NSURLConnection protocol attribute to the class,
@interface className : NSObject <NSURLConnectionProtocol>
IBOutlet UIActivityIndicatorView *activityIndicator ;
Then connect the ActivityIndicatorView in your xib file to this outlet, also set the hidden
property to true, and the hides when stopped property to true, using the attributes inspector.
then you would call the startAnimating: method on the activityIndicator variable, from the
method you use to start the NSURLConnection request, like this.
[activityIndicator startAnimating] ;
And use the stopAnimating: method of the activityIndicator, from the method you use to
verify the connection data has been recieved, like this.
[activityIndicator stopAnimating] ;
In iOS 4.3 the NSURLConnection has a connectionDidFinishLoading : method, and a
delegate method connection : didFailWithError : , which you could use to stop the
activity indicator in either case, but I'm not sure if these methods are still available in iOS 5.
Check out the developer documentation, on the NSURLConnection class, and delegate
methods to find the appropriate methods for checking the completed download.
This guide is probably worth reading as well.
Hope this is of some help.