有没有可以在 iPhone 上使用的简单开源 HUD(类似于 MBProgressHUD)?

发布于 2024-09-30 21:37:30 字数 294 浏览 3 评论 0原文

我不想使用 MBProgressHUD,因为线程和管理后台请求的开销。我不需要后台任务处理程序。只需一个简单的、线程安全的处理视图/窗口的库就可以完成这项工作。另外,如果不从不同的视图控制器创建实例并添加/删除它,我认为这对消费者来说工作量太大了。我应该能够从代码中的任何地方调用它。 像这样的事情:
<代码> [SimpleHud getInstance] pop];
[SimpleHud getInstance] pop withTitle:@"Doing stuff"];
[SimpleHud getInstanca]隐藏];

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];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

山田美奈子 2024-10-07 21:37:30

我喜欢 David Sinclair 的 DSActivityView。它比 MBProgressHUD 更轻,但不是轻量级。值得一看。

I like David Sinclair's DSActivityView. It's lighter than MBProgressHUD, though not featherweight. Worth taking a look.

锦上情书 2024-10-07 21:37:30

这就是我的想法:

   -(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];
    }

类是一个简单的 UIViewController。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文