使用loaddata无法正常工作

时间:2009-12-09 04:31:39

标签: iphone objective-c

我在本地桌面上有文件。

我正在使用[NSURL fileURLWithPath:filePath]转换其网址但我收到错误。这是我的代码:

NSString* filePath = @"/Users/Desktop/bb.ppt";
[powerWeb loadData:[NSData dataWithContentsOfFile:filePath]    
          MIMEType:@"application/vnd.ms-powerpoint"
  textEncodingName:@"utf-8"
           baseURL:[NSURL fileURLWithPath:filePath]];   

它给了我这个错误:

error:::Operation could not be completed. (NSURLErrorDomain error 100.)
error:::Frame load interrupted.

3 个答案:

答案 0 :(得分:1)

我怀疑这不对:

baseURL:[NSURL fileURLWithPath:filePath]

您在loadDatabaseURL部分使用相同的完整路径。

您是否在该位置有一个文件:/Users/Desktop/bb.ppt,即使您拥有该文件,我怀疑它会尝试访问/Users/Desktop/bb.ppt/Users/Desktop/bb.ppt设置baseURL

答案 1 :(得分:1)

以下内容适用于您:

[[NSBundle mainBundle] URLForResource:@"mypresentation" withExtension:@"ppt];

答案 2 :(得分:0)

我使用此代码在iPhone应用程序中显示ppt:

  

[myWebView loadRequest:[NSURLRequest   requestWithURL:[NSURL   fileURLWithPath:tempFilePath]]];

但是在查看时它有泄漏。我不知道为什么。