我正在加载webview
并使用SVProgressHUD
在页面加载时显示加载消息。
这是我的代码:
- (void)viewDidLoad{
[super viewDidLoad];
_infowebView.delegate = self;
NSURL *url = [NSURL URLWithString:@"http://example.com"];
[self.infowebView loadRequest:[NSURLRequest requestWithURL:url]];
}
- (void)webViewDidStartLoad:(UIWebView *)webView {
[SVProgressHUD showWithStatus:@"Loading"];
}
如果没有可用的互联网连接,是否可以显示错误消息,如果有,我该怎么做?
答案 0 :(得分:0)
在加载页面之前,您可以使用可访问性类检查互联网连接:
Session session = sessionFactory.getCurrentSession();
if(session != null && bean != null) {
session.update(bean);
}
使用方法:
+(BOOL)IsInternet
{
Reachability *networkReachability = [Reachability reachabilityForInternetConnection];
NetworkStatus networkStatus = [networkReachability currentReachabilityStatus];
if (networkStatus == NotReachable)
{
return NO;
}
else
{
return YES;
}
}