我知道這個問題已經在這裏提出。但是我面臨着一些尚未解決的問題。使用本地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.}
應該有'NSURL.fileURL'代替NSURL URLWithString可能是幫助 –
我試着用我提到的問題本身,但沒有運氣,它叫做didstartdownloa d和didfail委託方法。 – Sandy
你有沒有檢查該文件是否退出路徑或不?,使用fileManager fileExistsAtPath –