我知道这个问题已在这里提出。但是我面临一些问题没有得到解决。
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];
错误:
网址: 文件:///Users/Sanoj/Library/Developer/CoreSimulator/Devices/722-6542-4E14-9CC5-24F96EE305D9/data/Containers/Data/Application/B990D3-4311-B580-D2E00E75/Documents/AttachmentsFolder/Scrum_Methodology.pdf
错误域= NSURLErrorDomain代码= -1001“请求超时。” UserInfo = {NSUnderlyingError = 0x60800084d950 {错误 Domain = kCFErrorDomainCFNetwork Code = -1001“请求超时。” 的UserInfo = {NSErrorFailingURLStringKey =文件:///用户/ Sanoj /库/开发商/ CoreSimulator /设备/ 722CC1FA-6542-4E14-9CC5-24F96EE305D9 /数据/容器/数据/应用/ B992A9C0-A0D3-4311-B580-D2E0049CFE75 /文件/ AttachmentsFolder / Scrum_Methodology.pdf, NSErrorFailingURLKey =文件:///用户/ Sanoj /库/开发商/ CoreSimulator /设备/ 722CC1FA-6542-4E14-9CC5-24F96EE305D9 /数据/容器/数据/应用/ B992A9C0-A0D3-4311-B580-D2E0049CFE75 /文档/ AttachmentsFolder /Scrum_Methodology.pdf, _kCFStreamErrorCodeKey = -2102,_kCFStreamErrorDomainKey = 4,NSLocalizedDescription =请求超时。}}, NSErrorFailingURLStringKey =文件:///用户/ Sanoj /库/开发商/ CoreSimulator /设备/ 722CC1FA-6542-4E14-9CC5-24F96EE305D9 /数据/容器/数据/应用/ B992A9C0-A0D3-4311-B580-D2E0049CFE75 /文档/ AttachmentsFolder /Scrum_Methodology.pdf, NSErrorFailingURLKey =文件:///用户/ Sanoj /库/开发商/ CoreSimulator /设备/ 722CC1FA-6542-4E14-9CC5-24F96EE305D9 /数据/容器/数据/应用/ B992A9C0-A0D3-4311-B580-D2E0049CFE75 /文档/ AttachmentsFolder /Scrum_Methodology.pdf, _kCFStreamErrorDomainKey = 4,_kCFStreamErrorCodeKey = -2102,NSLocalizedDescription =请求超时。}
答案 0 :(得分: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]];
请检查