- (void) incrementBar: (id) timer { amountDone += 1.0f; [progressView setProgress: (amountDone / 20.0)]; if (amountDone > 20.0) { [self.actionSheet dismissWithClickedButtonIndex:0 animated:YES]; self.actionSheet = nil; [timer invalidate]; } } // Load the progress bar onto an actionsheet backing -(void) action: (UIBarButtonItem *) item { amountDone = 0.0f; self.actionSheet = [[[UIActionSheet alloc] initWithTitle:@"Downloading data. Please Wait\n\n\n" delegate:nil cancelButtonTitle:nil destructiveButtonTitle: nil otherButtonTitles: nil] autorelease]; progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(0.0f, 40.0f, 220.0f, 90.0f)]; [progressView setProgressViewStyle: UIProgressViewStyleDefault]; [actionSheet addSubview:progressView]; [progressView release]; // Create the demonstration updates [progressView setProgress:(amountDone = 0.0f)]; [NSTimer scheduledTimerWithTimeInterval: 0.35 target: self selector:@selector(incrementBar:) userInfo: nil repeats: YES]; [actionSheet showInView:self.view]; progressView.center = CGPointMake(actionSheet.center.x, progressView.center.y); }效果以下: