0
我正在加載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"];
}
Is it possible to show an error message if there isn't an internet connection available, if so how would i do this?
重複的http://stackoverflow.com/questions/477852/checking-for-internet-connectivity-in-objective-c – Darshana
你可以檢查互聯網連接,然後啓動互聯網所需的代碼,使用[可讀性類](https:///developer.apple.com/library/content/samplecode/Reachability/Introduction/Intro.html)。 – vaibhav
我只是用這個: - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)錯誤{SVProgressHUD showInfoWithStatus:@「Internet Connection Unavailable」]; [UIApplication sharedApplication] .networkActivityIndicatorVisible = NO; }這是不好的做法? – user1419810