From 123a0275ba75874b430d1ce95697e741696a3f18 Mon Sep 17 00:00:00 2001 From: wushenghua Date: Mon, 10 Apr 2017 18:05:25 +0800 Subject: [PATCH] fix bug --- Podfile | 1 + Sources/Controller/ASHRNViewController.m | 9 +++++++++ Sources/Utils/ASHDownFileUtil.m | 3 +-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Podfile b/Podfile index de950d0..e68d0dc 100644 --- a/Podfile +++ b/Podfile @@ -3,6 +3,7 @@ platform :ios,8.0 target 'ASHReactNative’ do source 'https://github.com/CocoaPods/Specs.git' +#React 用了0.42的版本,要在下面的源才有 source 'https://github.com/Artsy/Specs.git' pod 'React' =>'0.42.0' pod 'React/Core' =>'0.42.0' diff --git a/Sources/Controller/ASHRNViewController.m b/Sources/Controller/ASHRNViewController.m index e9ec909..1ed1e45 100644 --- a/Sources/Controller/ASHRNViewController.m +++ b/Sources/Controller/ASHRNViewController.m @@ -113,6 +113,15 @@ - (void)rnView:(ASHRNView *)rnView didFailed:(NSError *)error { [MBProgressHUD hideHUDForView:self.view animated:YES]; + MBProgressHUD* progressHUD = [[MBProgressHUD alloc] initWithFrame:self.view.bounds]; + + progressHUD.removeFromSuperViewOnHide = YES; + progressHUD.center = self.view.center; + progressHUD.label.text = @"加载失败"; + [self.view addSubview:progressHUD]; + + [progressHUD showAnimated:YES]; + [progressHUD hideAnimated:YES afterDelay:1.0]; } - (void)rnViewDidRenderFinish:(ASHRNView *)rnView { diff --git a/Sources/Utils/ASHDownFileUtil.m b/Sources/Utils/ASHDownFileUtil.m index 1d9fe4f..f7f535f 100644 --- a/Sources/Utils/ASHDownFileUtil.m +++ b/Sources/Utils/ASHDownFileUtil.m @@ -20,8 +20,7 @@ AFHTTPSessionManager* sessionManager = [AFHTTPSessionManager manager]; NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]]; NSURLSessionDownloadTask* task = [sessionManager downloadTaskWithRequest:request progress:nil destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) { -// return [NSURL fileURLWithPath:filePath]; - return [NSURL URLWithString:filePath]; + return [NSURL fileURLWithPath:filePath]; } completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) { if (!error) { if (completedBlock) {