Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display a progress indicator overlay/HUD on iPhone?

Tags:

I want to display a progress indicator in a semi-transparent box that floats over a table view. In other words, when the table contents are being downloaded, I want an "Updating" label to appear over it.

I have seen this in several apps in the store, notably Facebook (when you shake to reload) and Darkslide.

My first impulse is to create a semi-transparent UIView, place a UILabel and a UIProgressIndicatorView inside it, and add it to the view hierarchy... but where? A UIView may not overlap its siblings, so I can't make it a subview of the window. I also can't make it a subview of the table, because then it will scroll up and down with the table content.

I thought about creating a new UIWindow, but the documentation basically says don't.

I know CALayers can overlap each other, so that would be an option, but I can't put a progress indicator inside a CALayer, can I? Should I roll my own progress indicator that animates a CALayer instead of a UIView?

I'm not interested in hearing about private APIs.

Edit: The question was based on a faulty assumption. NSViews (on Mac OS X) may not overlap, but UIViews on the iPhone may.

like image 643
benzado Avatar asked Feb 27 '09 00:02

benzado


People also ask

What is progress bar in Iphone?

The progress bar shows installation progress. The amount of time depends on the number of files on the device and whether you're erasing, updating, or upgrading your iOS or iPadOS. This process can take as little as a minute if your device has little or no data or if you're erasing the device.

How do I add a progress bar in Swift?

To create your progress bar, you need to add a UIProgressView . Still in the storyboard, drag a new Progress View from the Library inside the Loading View.


1 Answers

I've just posted a HUD version of mine : https://github.com/y0n3l/LGViewHUD

you can get this result very easily :

#import "LGViewHUD.h" ....  LGViewHUD* hud = [LGViewHUD defaultHUD]; hud.activityIndicatorOn=YES; hud.topText=@"The longer...."; hud.bottomText=@"The better !"; [hud showInView:self.view]; 

enter image description here

Once the task is ended, just invoke

[[LGViewHUD defaultHUD] hideWithAnimation:HUDAnimationHideFadeOut]; 

and that's it !

like image 54
yonel Avatar answered Nov 03 '22 09:11

yonel