iPhoneバッファビューUIActivityIndicatorView


The UIActivityIndicatorView class creates and manages an indicator showing the indeterminate progress of a task. Visually, this indicator is a “gear” that is animated to spin.
You control when the progress indicator animates with the startAnimating and stopAnimating methods. If the hidesWhenStopped property is set to YES, the indicator is automatically hidden when animation stops.
简単な応用~.h
//
//  UIActivityIndicatorViewViewController.h
//  UIActivityIndicatorView
//
//  Created by Adam Libonatti-Roche on 26/10/2009.
//  Copyright Xogos 2009. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface UIActivityIndicatorViewViewController : UIViewController {
	IBOutlet UIButton *startSpin;
	IBOutlet UIButton *stopSpin;
	
	UIActivityIndicatorView *spinner;
}

- (IBAction) startSpinner;
- (IBAction) stopSpinner;

@end
~  .m
//
//  UIActivityIndicatorViewViewController.m
//  UIActivityIndicatorView
//
//  Created by Adam Libonatti-Roche on 26/10/2009.
//  Copyright Xogos 2009. All rights reserved.
//

#import "UIActivityIndicatorViewViewController.h"

#define kScreenWidth 320
#define kScreenHeight 480

@implementation UIActivityIndicatorViewViewController

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
	spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
	[spinner setCenter:CGPointMake(kScreenWidth/2.0, kScreenHeight/2.0)]; // I do this because I'm in landscape mode
	// spinner is not visible until started
	[self.view addSubview:spinner];
	[spinner release];
    [super viewDidLoad];
}

- (IBAction) startSpinner {
	[spinner startAnimating];
}

- (IBAction) stopSpinner {
	[spinner stopAnimating];
}




- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
	[stopSpin release];
	[startSpin release];
	[spinner release];
    [super dealloc];
}

@end