In Android development, I use a ProgressDialog to give me a dialog with a 'spinny', some text and a cancel button. I use this combined with a CountdownTimer to perform an action after 10 seconds unless the user cancels the dialog.
I have searched around for an equivalent in iOS, such as the open source SVProgressHUD and MBProgressHUD but none seem to support the addition of a button.
Do I have to write my own, or does anyone know of an easy way to achieve this?
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
indicator.frame = CGRectMake(0.0, 0.0, 40.0, 40.0);
indicator.center = self.view.center;
[self.view addSubview:indicator];
[indicator bringSubviewToFront:self.view];
[UIApplication sharedApplication].networkActivityIndicatorVisible = TRUE;
Write below code when you want to show indicator
[indicator startAnimating];
write below code when you want to hide indicator
[indicator stopAnimating];
was found at How to programmatically add a simple default loading(progress) bar in iphone app
UPD: you can create alert dialog without buttons and add any custom elements manually:
UIAlertView *alert;
...
alert = [[UIAlertView alloc] initWithTitle:@"\n\nConfiguring Preferences\nPlease Wait..." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil]; //display without any btns
// alert = [[UIAlertView alloc] initWithTitle:@"\n\nConfiguring Preferences\nPlease Wait..." message:nil delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles: nil]; //to display with cancel btn
[alert show];
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
// Adjust the indicator so it is up a few pixels from the bottom of the alert
indicator.center = CGPointMake(alert.bounds.size.width / 2, alert.bounds.size.height - 50);
[indicator startAnimating];
[alert addSubview:indicator];
To dismiss alert, just do
[alert dismissWithClickedButtonIndex:0 animated:YES];
More information at: http://iosdevelopertips.com/user-interface/uialertview-without-buttons-please-wait-dialog.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With