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];
有任何人知道如何解決這個問題?謝謝。