Use ActivityIndicator In iPhone

The iPhone SDK provides the UIActivityIndicatorView to tell a user to “Please wait,I’m processing”. The UIActivityIndicatorView uses a spinning “gear” to tell a user an application is processing and that it will eventually complete.

Step 1: Create a View-base application using template. Give the name of the application ActivityIndicator.

Step 2:  Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: Expand classes and notice Interface Builder created the ActivityIndicatorViewController class for you. Expand Resources and notice the template generated a separate nib, ActivityIndicatorViewController.xib for the ActivityIndicatorViewController.

Step 4: Open ActivityIndicatorViewController , add an IBOutlet for a UIActivityIndicatorView, and add an IBAction called PressMe. Make the following changes in the ActivityIndicatorViewController.h file.

 

 

 

Step 5: Double click your ActivityIndicatorViewController.xib file and open it to the Interface Builder. First,drag Round Rect button from the library and place it to the view window. Double click it and give the name PressMe. Now single click it and drag from the Touch Up Inside to the File’s Owner icon select PressMe: action. Drag activity indicator view from the library and place it to the view window. Connect File’s Owner to the activity indicator and select activityView. Save your .xib file and go back to the Xcode.

Step 6: Now make the following changes in the ActivityIndicatorViewController.m file.

 

 

 

Step 7:  Compile and run the application in the simulator.

You can downloaded SourceCode from here ActivityIndicator 2

Leave a Comment: