views:

2478

answers:

4

I have a case where i pull information from a server. My application has both a tab bar and navigation buttons. I want the application to show a progress indicator and disable all other controls so that user can't jump around while the data is being pulled from the server. How can i achieve this?

One approach i have in mind is to show a transparent view with a progress window (much like the message alert window - which allows the user to interact with the message alert window only). I need help in implementing this approach.

Currently, when the information/data is being pulled from the server i add a UIActivityView to the subview and start animating it. But this does not restrict the user from navigating to other parts of the application.

+1  A: 

Just create an UIAlertView with no buttons, it will prevent any user interaction.

You can add an UIProgressView or UIActivityIndicatorView to your alert if you want.

The method is described on my blog: http://blog.coriolis.ch/2008/11/09/add-an-uiprogressview-or-uiactivityindicatorview-to-your-uialertview/

Stephan Burlot
A: 

In this case i will have to open the alert in a separate thread (i'm sure). And how can i command it to close, when i'm done?

Plus, any idea about how to open the alert box in a separate thread would be great. Thanks.

Mustafa
+4  A: 

Stephan suggested the use of UIAlertView with UIProgressView or UIActivityIndicatorView. This solution worked for me, but as discussed with some of the other members of iPhone developer community, this approach is not recommended.

The recommended approach is to use a new view and set its transparancy value to alpha 7 or 8, set it's background to black, and add UIProgressView or UIActivityIndicatorView in this view and use this new view to show progress. No hack is involved in using this technique. While, incase of adding UIActivityIndicatorView to a UIAlertView, your actually performing a non-documented operation (which is not recommended).

Thanks.

Mustafa
A: 

Doing UI operations in new threads is in general not recommended. I's probably better to keep the main thread free and do your pulling in a new thread.

It's a bit late but this this might help you out (the class and discussion).

Matej Bukovinski
Thanks for sharing the link. It's always interesting to see how other people have solved a problem.
Mustafa