How to use activity indicator view on iPhone?

IphoneAndroid ActivityIndicator

Iphone Problem Overview


An activity indicator view is useful in many applications. Any ideas about how to add, activiate and dismiss an activity indicator view on iPhone?

All the methods for this are welcomed here.

Iphone Solutions


Solution 1 - Iphone

Create:

spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[spinner setCenter:CGPointMake(kScreenWidth/2.0, kScreenHeight/2.0)]; // I do this because I'm in landscape mode
[self.view addSubview:spinner]; // spinner is not visible until started

Start:

[spinner startAnimating]; 

Stop:

 [spinner stopAnimating];

When you're finally done, remove the spinner from the view and release.

Solution 2 - Iphone

Take a look at the open source WordPress application. They have a very re-usable window they have created for displaying an "activity in progress" type display over top of whatever view your application is currently displaying.

http://iphone.trac.wordpress.org/browser/trunk

The files you want are:

  • WPActivityIndicator.xib
  • RoundedRectBlack.png
  • WPActivityIndicator.h
  • WPActivityIndicator.m

Then to show it use something like:

[[WPActivityIndicator sharedActivityIndicator] show];

And hide with:

[[WPActivityIndicator sharedActivityIndicator] hide];

Solution 3 - Iphone

in regards to:

> Take a look at the open source WordPress application. They have a very re-usable window they have created for displaying an "activity in progress" type display over top of whatever view your application is currently displaying.

note that if you do utilise this code you MUST provide ALL the sourcecode to your own application to any user that requests it. You need to be aware that they may decide to repackage your code and sell it on the store themselves. This is all provided for under the terms of the GNU General Public License (GPL).

If you don't want to be forced into opening your sourcecode then you cannot use anything from the wordpress iphone application including the, referenced activity progress window, without forcing the GPL to apply to your own.

Solution 4 - Iphone

The documentation on this is pretty clear. It's a UIView subclass so you use it like any other view. To start/stop the animation you use

[activityIndicator startAnimating];
[activityIndicator stopAnimating];

Solution 5 - Iphone

Using Storyboard-

Create-

Go to main.storyboard (This can be found in theProject Navigator on the left hand side of your Xcode) and drag and drop the "Activity Indicator View" from the Object Library.

Activity Indicator View from Object Library

Go to the header file and create an IBOutlet for the UIActivityIndicatorView-

     @interface ViewController : UIViewController

         @property (nonatomic,strong) IBOutlet UIActivityIndicatorView *activityIndicatorView;

     @end

- Establish the connection from the Outlets to the UIActivityIndicatorView.

Start:

Use the following code when you need to start the activity indicator using following code in your implementation file(.m)-

 [self.activityIndicatorView startAnimating];

Stop:

Use the following code when you need to stop the activity indicator using following code in your implementation file(.m)-

 [self.activityIndicatorView stopAnimating];

Solution 6 - Iphone

i think you should use hidden better.

activityIndicator.hidden = YES

Solution 7 - Iphone

Activity indicator 2 sec show and go to next page

@property(strong,nonatomic)IBOutlet UIActivityIndicator *activityindctr;

-(void)viewDidload { [super viewDidload];[activityindctr startanimating]; [self performSelector:@selector(nextpage) withObject:nil afterDelay:2];}

-(void)nextpage{ [activityindctr stopAnimating]; [self performSegueWithIdentifier:@"nextviewcintroller" sender:self];}

Solution 8 - Iphone

- (IBAction)toggleSpinner:(id)sender
{
	if (self.spinner.isAnimating)
    {
		[self.spinner stopAnimating];
		((UIButton *)sender).titleLabel.text = @"Start spinning";
		[self.controlState setValue:[NSNumber numberWithBool:NO] forKey:@"SpinnerAnimatingState"];
	}
	else
    {
		[self.spinner startAnimating];
		((UIButton *)sender).titleLabel.text = @"Stop spinning";
		[self.controlState setValue:[NSNumber numberWithBool:YES] forKey:@"SpinnerAnimatingState"];
	}
}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionChilly ZhongView Question on Stackoverflow
Solution 1 - IphoneJane SalesView Answer on Stackoverflow
Solution 2 - IphoneLoungesView Answer on Stackoverflow
Solution 3 - IphoneDani LlewellynView Answer on Stackoverflow
Solution 4 - IphonenduplessisView Answer on Stackoverflow
Solution 5 - IphoneNatashaView Answer on Stackoverflow
Solution 6 - IphoneBinView Answer on Stackoverflow
Solution 7 - IphoneBibin JosephView Answer on Stackoverflow
Solution 8 - IphoneP.J.RadadiyaView Answer on Stackoverflow