iphone – MBProgressHUD没有显示

iphone – MBProgressHUD没有显示,第1张

概述在我的应用程序中,我正在加载一个资源密集的视图,加载大约需要1到2秒.所以我将它加载到一个单独的线程中,如下所示: hud = [[MBProgressHUD alloc] init];[hud showWhileExecuting:@selector(loadWorkbench:) onTarget:self withObject:nil animated:YES]; 但它永远不会出现,应用程 在我的应用程序中,我正在加载一个资源密集的视图,加载大约需要1到2秒.所以我将它加载到一个单独的线程中,如下所示:

hud = [[MBProgressHUD alloc] init];[hud showWhileExecuting:@selector(loaDWorkbench:) onTarget:self withObject:nil animated:YES];

但它永远不会出现,应用程序看起来冻结给最终用户.我出错了什么想法?

解决方法 是.它不会出现,因为你永远不会告诉我将HUD添加为窗口的子视图.尝试类似的东西:

// Should be initialized with the windows frame so the HUD disables all user input by covering the entire screen    HUD = [[MBProgressHUD alloc] initWithWindow:[UIApplication sharedApplication].keyWindow];    // Add HUD to screen    [self.vIEw.window addSubvIEw:HUD];    // Register for HUD callbacks so we can remove it from the window at the right time    HUD.delegate = self;    HUD.labelText = NSLocalizedString(@"Loading Workbench",nil);    HUD.detailsLabelText = NSLocalizedString(@"please wait",nil);    // Show the HUD while the provIDed method executes in a new thread    [HUD showWhileExecuting:@selector(loaDWorkbench:) onTarget:self withObject:nil animated:YES];

由于您将自己设置为HUD委托,因此还要添加以下委托方法:

- (voID)huDWasHIDden {    // Remove HUD from screen     [HUD removeFromSupervIEw];    // add here the code you may need}

并记得在相应的头文件中添加MBProgressHUDDelegate.

总结

以上是内存溢出为你收集整理的iphone – MBProgressHUD没有显示全部内容,希望文章能够帮你解决iphone – MBProgressHUD没有显示所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1086255.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-27
下一篇2022-05-27

发表评论

登录后才能评论

评论列表(0条)

    保存