首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MBProgressHUD将消息一个一个地显示在另一个之上

MBProgressHUD将消息一个一个地显示在另一个之上
EN

Stack Overflow用户
提问于 2012-01-30 00:05:00
回答 1查看 746关注 0票数 0

在viewDidload方法中,我使用MBProgressHUD显示一个活动指示器,直到从网上下载数据,然后检查应用程序是否启用了GPS。基于此,我使用MBProgressHUD提醒用户。

我的代码;

ViewDidLoad

代码语言:javascript
复制
hudForDownloadData = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view hudForDownloadData ];   
hudForDownloadData .delegate = self;
hudForDownloadData .labelText = @"Loading";
hudForDownloadData .detailsLabelText = @"updating data";
[hudForDownloadData showWhileExecuting:@selector(downloadDataFromWebService) onTarget:self withObject:nil animated:YES];

[self downloadDataFromWebService]; // This method is called, and then data is downloaded from the webservice, once the data is downloaded i will remove the `MBProgressHUD ` alert

现在,我正在检查应用程序是否启用了对GPS的访问,如果没有,则警告用户。

代码语言:javascript
复制
 hudForGPS = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
     [self.navigationController.view addSubview:HUD];   
     hudForGPS .delegate = self;
     hudForGPS .labelText = @"Loading";
     hudForGPS .detailsLabelText = @"updating data";
     [hudForGPS showWhileExecuting:@selector(checkIfApplicationEnabledGPS)
onTarget:self withObject:nil animated:YES]; // This will only take a
 maximum of 2-3 seconds. and i will remove it after that

问题是,当互联网/wifi中断时,hudForDownloadData将持续显示动画(显示uiactivityindicator)。同时,hudForGPS也将执行。但它将显示在hudForDownloadData下面。因此,用户将无法看到它。

我想要做的是首先执行checkIfApplicationEnabledGPS,并等待它的警报结束(只需要2-3秒),然后加载执行downloadDataFromWebService,如果互联网/wifi不可用,它将永远显示。

我如何通过编程来做到这一点呢?

EN

回答 1

Stack Overflow用户

发布于 2012-01-30 03:28:02

首先执行checkIfApplicationEnabledGPS,当它完成时,你会显示一个警告框,如果你使用UiAlertView来显示警告,那么你可以处理它的委托:-

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

当用户在UiAlert视图中按下ok按钮时,您可以用hudForDownloadData覆盖上面的委托

这样,checkIfApplicationEnabledGPS和hudForDownloadData都将被相继执行

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9054557

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档