在viewDidload方法中,我使用MBProgressHUD
來顯示一個活動指示器,直到從網上下載數據,然後檢查應用程序是否已啓用GPS。基於此,我提醒用戶使用MBProgressHUD
。MBProgressHUD顯示消息一個在另一個上
我的代碼;
viewDidLoad中
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,並提醒用戶,如果不是我檢查。
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
問題是:當互聯網/無線網絡關閉時,hudForDownloadData
將持續動畫(顯示uiactivityindicator)。同時hudForGPS
也會執行。但它將顯示在hudForDownloadData
以下。所以用戶將無法看到它。
我想要做的是首先執行checkIfApplicationEnabledGPS
,然後等到其警報結束(僅需要2-3秒),然後加載執行downloadDataFromWebService
,如果internet/wifi不可用,它將會永遠顯示。
如何以編程方式執行此操作?
我需要在這兩種情況下使用自定義警報(MBProgressHUD) – Illep 2012-01-30 00:36:30
在這種情況下也不會有問題,您可以創建自己的alertview並可以處理自己的按鈕的IBactions – 2012-01-30 05:07:13
hudWasHidden,是否使用此代理的MBProgressHUD checkIfApplicationEnabledGPS完成了嗎? – 2012-01-30 05:11:52