UIProgressView in UIAlertView?

While I'm exporting data to a server I'd like to show some sort of progress bar. So far I haven't thought of a decent way to handle that, other than to pop up an alert view with a progress bar. Except I don't see anything in UIAlertView for adding anything other buttons.

I googled and found an o'reilly article, but it appears to be rather out of date. At least, it doesn't work for me. I'm pretty sure I've seen another app do this, but I can't remember which one off the top of my head.

Any suggestions? Is there a better way to do this?

15 Al PowerBook G4, Mac OS X (10.5.4)

Posted on Oct 2, 2008 9:35 PM

Reply
5 replies
Sort By: 

Oct 3, 2008 1:07 AM in response to Brandon Fosdick

You just need to add a UIProgressView to your UIAlertView:
This snippet also creates an UIActivityIndicatorView if needed.

- (void) createProgressionAlertWithMessage:(NSString *)message withActivity:(BOOL)activity
{
 progressAlert = [[UIAlertView alloc] initWithTitle: message
 message: @"Please wait..."
 delegate: self
 cancelButtonTitle: nil
 otherButtonTitles: nil];
 
 
 // Create the progress bar and add it to the alert
 if (activity) {
 activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
 activityView.frame = CGRectMake(139.0f-18.0f, 80.0f, 37.0f, 37.0f);
 [progressAlert addSubview:activityView];
 [activityView startAnimating];
 } else {
 progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(30.0f, 80.0f, 225.0f, 90.0f)];
 [progressAlert addSubview:progressView];
 [progressView setProgressViewStyle: UIProgressViewStyleBar];
 }
 [progressAlert show];
 [progressAlert release];
}
Reply

Nov 9, 2008 7:30 AM in response to Stephan Burlot

Hi

I was using the code mentioned in this post with some modifications. If I add a Cancel button or any other button to the alert view along with the progress view, the button clicks stop working! Is there a way around this? I want the user to be able to cancel an upload! Please help!
Reply

Dec 15, 2008 3:31 AM in response to genapp

You just have to change the subview rect that you're drawing the UIProgressView in, otherwise the subview covers the button on the UIAlertView and won't allow the user to click it.

Try something like this:

progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(30.0f, 68.0f, 225.0f, 13.0f)];
Reply

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

UIProgressView in UIAlertView?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.