iOS – UIActivityIndicatorView example…

 UIActivityIndicatorView is used to show that some long process is processing in background.It can be implemented programatically and using IBOutlet.

In this tutorial we are going to create a UIActivityIndicatorView programatically with start and stop animations.Lets get started,

Step 1: Create a new project in Xcode.

Step 2: Set property for UIActivityIndicatorView in .h file and set @synthesis in .m file.

.h file: 

@property (nonatomic,retain) UIActivityIndicatorView *activityIndicatorObject;

.m file:

@synthesis activityIndicatorObject;

Step 3: Now Initialize UIActivityIndicatorView object and set position.

// Initialize ActivityIndicator object

    activityIndicatorObject = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

// Set Center Position for ActivityIndicator

    activityIndicatorObject.center = CGPointMake(150, 150);

   // Add ActivityIndicator to your view

    [self.view addSubview:activityIndicatorObject];

Step 4: Add two buttons in xib and set Action as stopAnimating and startAnimating.These methods are used to start and stop ActivityIndicator.

- (IBAction)startAnimating:(id)sender

{

[activityIndicatorObject startAnimating]; 

}

 - (IBAction)stopAnimating:(id)sender

{

[activityIndicatorObject stopAnimating];

}

Step 5: Now Run the project.You are Done!!!

 

Advertisements

2 thoughts on “iOS – UIActivityIndicatorView example…”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s