“Please wait” dialog in iOS8

I used to have a “Please wait” dialog in my app for long time. It was quite simple thing using UIActivityIndicatorView and adding it to UIAlertView.

However iOS8 introduced UIAlertController. Is it possible to add anything to it to have similiar effect? Is there another way of doing such thing with iOS8?

I have searched a lot of sites and still have no idea how it can be done with the new API.

I would appreciate any answers – links to libs, tutorials etc., which could be helpful.



how to display please wait dialog during EXEC() function

how to display please wait dialog while EXEC() runs another application silently.

jquery implementation of Please Wait dialog – safari specific issue

My goal is to display a non-modal jquery-ui dialog box that will display a please wait message along with a loading animation. This dialog box would display on the page the user is coming from, not pr

Android – Loading, please wait

Is there a standard Loading, please wait dialog I can use in Android development, when I invoke some AsyncTask (downloading some data from remote service for example)?

Displaying a “Please Wait” Dialog for a Non-Thread Safe task

I am using 3rd party library and some of the functions of the library take a long time to execute so I want to display a Please Wait dialog while the functions are busy. Normally I would do somethin

jQuery “Please Wait, Loading…” animation?

I would like to place a please wait, loading spinning circle animation on my site. Where can I find a JQuery Please wait, loading animation plugin?

jQuery “Please Wait, Loading…” animation?

I would like to place a please wait, loading spinning circle animation on my site. Where can I find a JQuery Please wait, loading animation plugin?

“Please wait” message for

How to show Please wait message for <h:commandButton> ? . I knew how to show this modalPanel for <a4j:____Button>. This request for an existing application which has close to 40 pages ,

Show “Please wait” modal while function runs

I’m trying to add a jQuery UI modal dialog to show when a function starts, which says Please wait. Then have it close when the function is done. I’ve tried the following: function flashFallback(){ $

Rails “please wait” page

I have a rails app that imports all your Facebook contacts. This takes some time. I would like to be able to show a please wait page while the importing keeps happening in the back. It seems that I

Please Wait iPhone – No NSTimer

I am currently using NSTimer to load a Please Wait alert view in my application while it contacts a server. I want to get rid of this NSTimer and change it so that it runs the Please Wait alert vi


It seems to be impossible to do it plain old way using only basic API. I have decided to use DTAlertView which allows such modifications. It works as I wanted.


Try this I done some trick…

Below code is working for me in iPod iOS8beta5 + XCode6

UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil
                                        message:@"Please wait/n/n/n"

    UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    spinner.center = CGPointMake(130.5, 65.5);
    spinner.color = [UIColor blackColor];
    [spinner startAnimating];
    [alert.view addSubview:spinner];
    [self presentViewController:alert animated:NO completion:nil];

“Please wait” dialog in iOS8

If you only want to display title and activity indicator and you feel adventurous, you can hack AlertController’s view hierarchy. The code below works on 8.2. However this normally should not be in production.

@implementation AlertControllerWithActivityIndicator

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];

    UIView *scrollView = [self findViewByClassPrefix:@"_UIAlertControllerShadowedScrollView" inView:self.view];
    UIView *containerView = [scrollView.subviews firstObject];
    UILabel *titleLabel = containerView.subviews.firstObject;

    if(!titleLabel) {

    if(!self.indicatorView) {
        self.indicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
        self.indicatorView.translatesAutoresizingMaskIntoConstraints = NO;
        [containerView addSubview:self.indicatorView];
        NSDictionary *views = @{ @"text": titleLabel, @"indicator": self.indicatorView };

        NSArray *constraints = [scrollView constraintsAffectingLayoutForAxis:UILayoutConstraintAxisVertical];
        for(NSLayoutConstraint *constraint in constraints) {
            if(constraint.firstItem == containerView && constraint.secondItem == titleLabel && constraint.firstAttribute == NSLayoutAttributeBottom) {
                constraint.active = NO;

        [containerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[text]-[indicator]-24-|" options:0 metrics:nil views:views]];
        [containerView addConstraint:[NSLayoutConstraint constraintWithItem:self.indicatorView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:containerView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]];

        [self.indicatorView startAnimating];

- (UIView *)findViewByClassPrefix:(NSString *)prefix inView:(UIView *)view {
    for(UIView *subview in view.subviews) {
        if([NSStringFromClass(subview.class) hasPrefix:prefix]) {
            return subview;

        UIView *child = [self findViewByClassPrefix:prefix inView:subview];
        if(child) {
            return child;
    return nil;


Produces something like that:

“Please wait” dialog in iOS8

Instead of using a UIAlertController, you can use a custom UIViewController that is presented modally. Here is what I use in Swift 2.0:

class ActivityViewController: UIViewController {

    private let activityView = ActivityView()

    init(message: String) {
        super.init(nibName: nil, bundle: nil)
        modalTransitionStyle = .CrossDissolve
        modalPresentationStyle = .OverFullScreen
        activityView.messageLabel.text = message
        view = activityView

    required init(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")

private class ActivityView: UIView {

    let activityIndicatorView = UIActivityIndicatorView(activityIndicatorStyle: .WhiteLarge)
    let boundingBoxView = UIView(frame: CGRectZero)
    let messageLabel = UILabel(frame: CGRectZero)

    init() {
        super.init(frame: CGRectZero)

        backgroundColor = UIColor(white: 0.0, alpha: 0.5)

        boundingBoxView.backgroundColor = UIColor(white: 0.0, alpha: 0.5)
        boundingBoxView.layer.cornerRadius = 12.0


        messageLabel.font = UIFont.boldSystemFontOfSize(UIFont.labelFontSize())
        messageLabel.textColor = UIColor.whiteColor()
        messageLabel.textAlignment = .Center
        messageLabel.shadowColor = UIColor.blackColor()
        messageLabel.shadowOffset = CGSizeMake(0.0, 1.0)
        messageLabel.numberOfLines = 0


    required init(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")

    override func layoutSubviews() {

        boundingBoxView.frame.size.width = 160.0
        boundingBoxView.frame.size.height = 160.0
        boundingBoxView.frame.origin.x = ceil((bounds.width / 2.0) - (boundingBoxView.frame.width / 2.0))
        boundingBoxView.frame.origin.y = ceil((bounds.height / 2.0) - (boundingBoxView.frame.height / 2.0))

        activityIndicatorView.frame.origin.x = ceil((bounds.width / 2.0) - (activityIndicatorView.frame.width / 2.0))
        activityIndicatorView.frame.origin.y = ceil((bounds.height / 2.0) - (activityIndicatorView.frame.height / 2.0))

        let messageLabelSize = messageLabel.sizeThatFits(CGSizeMake(160.0 - 20.0 * 2.0, CGFloat.max))
        messageLabel.frame.size.width = messageLabelSize.width
        messageLabel.frame.size.height = messageLabelSize.height
        messageLabel.frame.origin.x = ceil((bounds.width / 2.0) - (messageLabel.frame.width / 2.0))
        messageLabel.frame.origin.y = ceil(activityIndicatorView.frame.origin.y + activityIndicatorView.frame.size.height + ((boundingBoxView.frame.height - activityIndicatorView.frame.height) / 4.0) - (messageLabel.frame.height / 2.0))

You use it like this:

let activitiyViewController = ActivityViewController(message: "Loading...")
presentViewController(activitiyViewController, animated: true, completion: nil)

And it will look like this:

“Please wait” dialog in iOS8

Swift 2.0:

 override func viewDidAppear(animated: Bool)

  let alertController = UIAlertController(title: nil, message: "Please wait/n/n", preferredStyle: UIAlertControllerStyle.Alert)

  let spinnerIndicator: UIActivityIndicatorView = UIActivityIndicatorView(activityIndicatorStyle: UIActivityIndicatorViewStyle.WhiteLarge)

  spinnerIndicator.center = CGPointMake(135.0, 65.5)
  spinnerIndicator.color = UIColor.blackColor()

  self.presentViewController(alertController, animated: false, completion: nil)


After some point, we need to hide the alert.

alertController.dismissViewControllerAnimated(true, completion: nil)

Swift 3.0

To show the progress dialog:

let alertController = UIAlertController(title: nil, message: "Please wait/n/n", preferredStyle: .alert)

let spinnerIndicator = UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge)

spinnerIndicator.center = CGPoint(x: 135.0, y: 65.5)
spinnerIndicator.color = UIColor.black

self.present(alertController, animated: false, completion: nil)

To dismiss the progress dialog:

alertController.dismiss(animated: true, completion: nil);