1
我今天开始实施UIDocumentPickerViewController
,我碰到了一堵砖墙。我已经得到它来导入文件,并为我提供NSURL
,但是当我使用iWork文档时,我使用的NSData为空。它可能是因为iWork文档是目录而不是文件,并且我看了一些关于StackOverflow的其他问题,除了压缩它们之外,它们似乎都没有帮助或提供解决方案,这在考虑完成时似乎是错误的在相应的iWork应用程序中使用共享表格,它工作正常。UIDocumentPickerViewController和iWork文档没有加载
这里是我的代码:
NSArray* components = [[url lastPathComponent] componentsSeparatedByString:@"."];
NSData* data = [[NSData alloc] initWithContentsOfURL:url];
NSString* filename = [[[url lastPathComponent] stringByReplacingOccurrencesOfString:[components lastObject] withString:@""] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSString* newPath = [NSString stringWithFormat:@"%@/tmpFiles/%@%@",[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0],filename,[components lastObject]];
[data writeToFile:newPath atomically:YES];
[self.files addObject:[NSURL fileURLWithPath:newPath]];
[self updateFileCount];
有任何人知道如何解决这个问题?谢谢。