I don't want to use MBProgressHUD because of the overhead for threads and managing background asks. I don't need a background task handler. Just a simple, thread safe library that deals with views/windows should do the job. Also without creating an instance from different view controllers and adding/removing it, I think its too much work for the consumer. I should be able to call it from anywhere in the code.
Something like this:
[SimpleHud getInstance] pop];
[SimpleHud getInstance] pop withTitle:@"Doing stuff"];
[SimpleHud getInstanca] hide];
Asked
Active
Viewed 1,614 times
1

Ibrahim Okuyucu
- 159
- 6
2 Answers
1
I like David Sinclair's DSActivityView. It's lighter than MBProgressHUD, though not featherweight. Worth taking a look.

Matthew Frederick
- 22,245
- 10
- 71
- 97
-
most examples refer to current view for showing it (i.e pass self.view as parameter). I wanted something that'll be child of parent window so that the original view which displayed the HUD can be dismissed while data is still loading. Also it can be invoked and hidden from different threads. – Ibrahim Okuyucu Dec 22 '10 at 04:21
-
Ah, gotcha. I don't see any reason why it couldn't be called on the parent window, but I certainly haven't tried it. – Matthew Frederick Dec 22 '10 at 04:49
0
This is what I come up with:
-(void)pop:(NSString *)text {
[self performSelectorOnMainThread:@selector(popLightBox:) withObject:text waitUntilDone:YES];
}
-(void)hide {
[self performSelectorOnMainThread:@selector(hideLightBox) withObject:nil waitUntilDone:YES];
}
-(void)popLightBox:(NSString *)text
{
NSArray *windows = [[UIApplication sharedApplication] windows];
NSInteger last = [windows count]-1;
if (last < 0) return;
UIWindow *currentWindow = [windows objectAtIndex:last];
[currentWindow addSubview:self.view];
if (text == nil) {
self.loadingLabel.text = __DEFAULT_LOADING_TEXT__;
}else {
self.loadingLabel.text = text;
}
}
-(void)hideLightBox
{
[self.view removeFromSuperview];
}
Class is a simple UIViewController.

Ibrahim Okuyucu
- 159
- 6
-(void)popLightBox { NSArray *windows = [[UIApplication sharedApplication] windows]; NSInteger last = [windows count]-1; if (last < 0) return; UIWindow *currentWindow = [windows objectAtIndex:last]; [currentWindow addSubview:self.view]; }
– Ibrahim Okuyucu Dec 21 '10 at 20:22