Return to Snippet

Revision: 58932
at August 10, 2012 03:02 by zopebie

Initial Code
// Showing progress 

NSTimer *timer;

- (void)updateProgress:(NSTimer *)sender
	UIProgressView *progress = [sender userInfo];
	//have we completed?
	if (progress.progress == 1.0)
		[timer invalidate];
		progress.progress += 0.05;

- (void)viewDidLoad {
    [super viewDidLoad];
	UIProgressView *myProgressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];
	CGRect progressFrame = CGRectMake(10,100,300,25);
	[myProgressView setFrame:progressFrame];
	[myProgressView setProgress:0.0];
	[self.view addSubview:myProgressView];
	//create timer
	timer = [[NSTimer scheduledTimerWithTimeInterval:0.1 
											 repeats:YES] retain];

// Showing Activity 

- (void)viewDidLoad {
    [super viewDidLoad];
	[self.view setBackgroundColor:[UIColor blackColor]];
	UIActivityIndicatorView *myActivityView = [[UIActivityIndicatorView alloc] 
	CGRect activityFrame = CGRectMake(130,100,50,50);
	[myActivityView setFrame:activityFrame];
	myActivityView.hidesWhenStopped = YES;	
	[myActivityView startAnimating];
	[self.view addSubview:myActivityView];

Initial URL

Initial Description
When performing tasks that may take some time, you often need to provide some kind of visual feedback to your users. If you know how long the task will take to complete, you can use a progress indicator to show the user how much of the task has been performed and how much still has to run. If you are unable to determine the duration of the task, use a “busy” indicator (such as the beach ball or hourglass on OS X).

iOS provides classes for showing both progress and activity.

Initial Title
Progress and Activity Indicators

Initial Tags

Initial Language
Objective C