UIActivityIndicatorView UIActionSheet modal loading screen
How do I show a loading screen? A modal loading indicator.
So you need to do a web request and wait for a response, you don’t want the user to interfere while this is happening? Welcome UIActionSheet and UIActivityIndicatorView.
So I send a multi-form http post request, and need to wait for a response.
Just before it sends I do the following
Note that I am inside a UIView → UIScrollView → UITabBarController
progressView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
progressView.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleRightMargin |
UIViewAutoresizingFlexibleTopMargin |
UIViewAutoresizingFlexibleBottomMargin);
UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:@"Uploading Company Info"
delegate:self
cancelButtonTitle:@"Stop"
destructiveButtonTitle:nil
otherButtonTitles:nil];
[menu addSubview:progressView];
[menu showInView:self.view];
[menu setBounds:CGRectMake(0,0,320, 175)];
[progressView startAnimating];
then do your code that will take some time..
once it is complete
I suggest doing whatever it is that takes a while (blocking web request) on another thread. I will go over how to do this on another post (Once I have it worked out, haha..)
Also, note I am in a UIViewController
controller. As it stands I haven’t shown you how to respond to the clicking of the ‘Stop‘ button. It will make the loading screen disappear by default.
Using the
will send that button click back to your controller on
and you can do as you please with it.
This is just a snippet to get you started. The numbers I have used above for dimension’s were worked out with trial and error. I primarily use the Interface Builder for my UI stuff so I’m yet to get my head around properly placing UI objects in views.
Related Posts
In: Iphone · Tagged with: iPhone, UIActionSheet, UIActivityIndicatorView
on August 28, 2012 at 8:42 pm
Permalink
Thanks a lot ! it’s exactly what i was looking for, you save my day !