我在AppDelegate.m文件中有这个代码,用Apple的Reachability库检查互联网连接:
reach = [Reachability reachabilityWithHostname:@"https://s3.amazonaws.com"];
reach.reachableBlock = ^(Reachability*reach)
{
dispatch_async(dispatch_get_main_queue(), ^{
[ProgressHUD dismiss];
NSLog(@"Reachable");
});
};
reach.unreachableBlock = ^(Reachability*reach)
{
dispatch_async(dispatch_get_main_queue(), ^{
[ProgressHUD show:@"Awaiting internet connection…" Interaction:NO];
NSLog(@"Not reachable");
});
};
[reach startNotifier];
NSLog(@"Starting notifier in didFinishLaunchingWithOptions");
然而,即使有互联网连接,ProgressHUD也不会解散 。这是我在iOS设备上构建和运行时收到的NSLog输出。
2014-10-13 16:19:12.100 iPwnStore[2814:939245] Starting notifier in didFinishLaunchingWithOptions
2014-10-13 16:19:12.158 iPwnStore[2814:939245] SCNetworkReachabilitySetDispatchQueue() failed: Invalid argument
2014-10-13 16:19:12.159 iPwnStore[2814:939245] Application did become active, starting notifier
2014-10-13 16:19:12.176 iPwnStore[2814:939245] Not reachable
我正在为iOS 8构建此应用程序,是否有人对如何解决此问题有任何想法?
修改:对于ProgressHUD,我使用的是:https://github.com/relatedcode/ProgressHUD
答案 0 :(得分:0)
加载HUD的视图应该相同,
For ex,
[MBProgressHUD showHUDAddedTo:**self.view** text:@"connecting..." animated:YES];
[MBProgressHUD hideHUDForView:**self.view** animated:YES];