Skip to content

Instantly share code, notes, and snippets.

@BenBarahona
Created March 6, 2012 01:02
Show Gist options
  • Select an option

  • Save BenBarahona/1982591 to your computer and use it in GitHub Desktop.

Select an option

Save BenBarahona/1982591 to your computer and use it in GitHub Desktop.
MBProgress HUD determinate
- (IBAction)showWithLabelDeterminate:(id)sender {
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
// Set determinate mode
HUD.mode = MBProgressHUDModeDeterminate;
HUD.delegate = self;
HUD.labelText = @"Loading";
// myProgressTask uses the HUD instance to update progress
[HUD showWhileExecuting:@selector(myProgressTask) onTarget:self withObject:nil animated:YES];
}
- (void)myProgressTask {
// This just increases the progress indicator in a loop
float progress = 0.0f;
while (progress < 1.0f) {
progress += 0.01f;
HUD.progress = progress;
usleep(50000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment