这是我的代码:
//1.Create caches
NSString *caches = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
self.filePath = [caches stringByAppendingPathComponent:@"xsb.ppt"];
DLog(@"%@",self.filePath);
//2.Create file manager
NSFileManager *fileManager = [NSFileManager defaultManager];
//create file
[fileManager createFileAtPath:self.filePath contents:nil attributes:nil];
//Use webView open ppt
NSURL *url = [[NSURL alloc] initFileURLWithPath:self.filePath];
self.request = [NSURLRequest requestWithURL:url];
[self.PPTWebView loadRequest:self.request];
webView错误:
cuoweuError Domain = WebKitErrorDomain Code = 102
谁能告诉我为什么?
答案 0 :(得分:0)
删除
[fileManager createFileAtPath:self.filePath contents:nil attributes:nil];
否则文件将被覆盖。
如果您想确保webview正确处理powerpoint文件,您可以尝试将.ppt文件添加到项目中,然后像这样打开它:
NSString * pathToPowerPointFile = [[NSBundle mainBundle]
pathForResource:@"xsb"
ofType:@"ppt"];
[self.PPTWebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:pathToPowerPointFile]]];