2017-06-20 3 views
0

私はこの質問がすでにここで尋ねられていることを知っていました。しかし、私は解決されていないいくつかの問題に直面しています。ローカルからのUIWebviewを使用してrtfとpdfをロードする

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *docsPath = [paths objectAtIndex:0]; 
    NSString *fileCacheDirPath = [docsPath stringByAppendingPathComponent:kATTACHMENTS_FOLDER]; 
    NSString *filePath = [fileCacheDirPath stringByAppendingPathComponent:_fileItemDataModel.name]; 
    NSURL *url = [NSURL fileURLWithPath:filePath isDirectory:NO]; 

エラー:

url : file:///Users/Sanoj/Library/Developer/CoreSimulator/Devices/722-6542-4E14-9CC5-24F96EE305D9/data/Containers/Data/Application/B990D3-4311-B580-D2E00E75/Documents/AttachmentsFolder/Scrum_Methodology.pdf

Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSUnderlyingError=0x60800084d950 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "The request timed out." UserInfo={NSErrorFailingURLStringKey=file:///Users/Sanoj/Library/Developer/CoreSimulator/Devices/722CC1FA-6542-4E14-9CC5-24F96EE305D9/data/Containers/Data/Application/B992A9C0-A0D3-4311-B580-D2E0049CFE75/Documents/AttachmentsFolder/Scrum_Methodology.pdf, NSErrorFailingURLKey=file:///Users/Sanoj/Library/Developer/CoreSimulator/Devices/722CC1FA-6542-4E14-9CC5-24F96EE305D9/data/Containers/Data/Application/B992A9C0-A0D3-4311-B580-D2E0049CFE75/Documents/AttachmentsFolder/Scrum_Methodology.pdf, _kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4, NSLocalizedDescription=The request timed out.}}, NSErrorFailingURLStringKey=file:///Users/Sanoj/Library/Developer/CoreSimulator/Devices/722CC1FA-6542-4E14-9CC5-24F96EE305D9/data/Containers/Data/Application/B992A9C0-A0D3-4311-B580-D2E0049CFE75/Documents/AttachmentsFolder/Scrum_Methodology.pdf, NSErrorFailingURLKey=file:///Users/Sanoj/Library/Developer/CoreSimulator/Devices/722CC1FA-6542-4E14-9CC5-24F96EE305D9/data/Containers/Data/Application/B992A9C0-A0D3-4311-B580-D2E0049CFE75/Documents/AttachmentsFolder/Scrum_Methodology.pdf, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=The request timed out.}

+0

をチェックNSURL.fileURL'代わりにNSURL URLWithStringが、その助けるかもしれ 'があるはずですしてください –

+0

私は質問自体に言及したように使ってみましたが、運はありません。didstartdownloaと呼ばれています。 dと代理人のメソッドをdidfailed。 – Sandy

+0

ファイルがパスで終了するかどうかチェックしましたか?fileManager fileExistsAtPath –

答えて

0

それは次のコード

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
      NSString *docsPath = [paths objectAtIndex:0]; 
      NSString *fileCacheDirPath = [docsPath stringByAppendingPathComponent:kATTACHMENTS_FOLDER]; 
      NSString *filePath = [fileCacheDirPath stringByAppendingPathComponent:_fileItemDataModel.name]; 
      [self.webView loadData:_fileItemDataModel.data MIMEType:@"application/pdf" textEncodingName:@"" baseURL:[NSURL URLWithString:filePath]]; 

で働いていたが、

関連する問題