Question

I want to use a some form of loading display while a background thread is being executed. I had considered using an Activity Indicator view but I feel it is not enough by itself. I would like to be able to prevent user interaction while loading is going on, therefore I thought about a hosting it on a UIAlertView. However I saw that Apple states that you The UIAlertView class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified. As a result I'm hesitant to put a loading indicator into a UIAlertView.

I had a look at other examples here, some which suggest the Custom UIAlertView approach. I am just wondering what is the best approach or some direction?

Am I correct in thinking the app will be refused if I customise the UIAlertView?

Thanks

Was it helpful?

Solution

use MBProgressHUD, it displays a translucent HUD with an indicator and/or labels while work is being done in a background thread. MBPreogressHUD, see example for more details

OTHER TIPS

I have done something like this. What I did was I used a translucent black view covering the whole window. Trap any events in this overlay to prevent clicking through on components below. This is acceptable, the app is in the App Store.

Take a look at MBProgressHUD - built exactly for this - https://github.com/jdg/MBProgressHUD

You can use MBProgressHUD standard library for it. Download it from this link

Shortly you can do it like this:

[MBProgressHUD showHUDAddedTo:self.view animated:YES];
[MBProgressHUD hideHUDForView:self.view animated:YES];

This MBProgressHUD link will help you to understand it

  1. Create notification and fire it back to the main thread in callout block of asynchronous thread.
  2. Create new special Activity View Controller with translucent self.view and add UIActivityView on it. Trap UIEvents on customized view and set it as self.view.
  3. Add this controller as listener to notification.
  4. When asynchronous process starts, add this view controller as child controller to existing controller, same with the self.view.
  5. When notification reached Activity View Controller notification triggered method, remove its view from superview, same with view controller, t.i. Activity View Controller.

In this way you will be more flexible to do anything you want with it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top