I have noticed that some apps like Safari and Mail show a loading indicator in the status bar (the bar at the very top of the phone) when they are accessing the network. Is there a way to do the same thing in SDK apps, or is this an Apple only thing?
+16
A:
It's in UIApplication:
UIApplication* app = [UIApplication sharedApplication];
app.networkActivityIndicatorVisible = YES;
Stephen Darlington
2008-10-03 13:06:14
Thanks that works perfectly. Just a side note: the simulator seems to ignore this value, which made me think at first it didn't work.
rustyshelf
2008-10-03 13:33:34
+1
A:
I've found the following macros pretty useful!
#define ShowNetworkActivityIndicator() [UIApplication sharedApplication].networkActivityIndicatorVisible = YES
#define HideNetworkActivityIndicator() [UIApplication sharedApplication].networkActivityIndicatorVisible = NO
So you can just call ShowNetworkActivityIndicator();
or HideNetworkActivityIndicator();
from within your app (as long as the header is included of course!).
Michael Waterfall
2009-11-17 18:51:08
Why not define a category on UIApplication? Seems much nicer (and more debuggable) than a #define.
Barry Wark
2009-11-17 18:56:48