Created
August 5, 2015 14:59
-
-
Save niwatako/67146b5657954bbddbeb to your computer and use it in GitHub Desktop.
WKWebViewのエラー処理は ユーザー操作によるキャンセルの error.code -999 を無視するべし。 #CodePiece
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error{ | |
if (error && !([error.domain isEqualToString:NSURLErrorDomain] && error.code == NSURLErrorCancelled)) { | |
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"Error : %ld",(long)error.code] | |
message:error.localizedDescription | |
preferredStyle:UIAlertControllerStyleAlert]; | |
[alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" | |
style:UIAlertActionStyleCancel | |
handler:nil]]; | |
// 続けるボタン | |
[alertController addAction:[UIAlertAction actionWithTitle:@"Retry" | |
style:UIAlertActionStyleDefault | |
handler:^(UIAlertAction *action) { | |
// リロード処理の実装 | |
}]]; | |
[self presentViewController:alertController animated:YES completion:nil]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment