我正在开发一个iOS应用程序,它可以使用DocumnetPicker导入云文件,在Xcode6.1,iphone5s(IOS8.1.1)下。奇怪的是,.number/.key文件的url不能成功加载,但.pdf/.jpg等其他文件就可以了。
我的UTIS:
+ (NSArray*) supportedDocumentTypes
{
return @[(__bridge NSString*) kUTTypeContent,
@"com.apple.iwork.pages.pages",
@"com.apple.iwork.numbers.numbers",
@"com.apple.iwork.keynote.key"];
}documentPicker:didPickDocumentAtURL:的定义与newbox示例相同:
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url {
BOOL startAccessingWorked = [url startAccessingSecurityScopedResource];
NSURL *ubiquityURL = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
NSLog(@"ubiquityURL %@",ubiquityURL);
NSLog(@"start %d",startAccessingWorked);
NSFileCoordinator *fileCoordinator = [[NSFileCoordinator alloc] init];
NSError *error;
[fileCoordinator coordinateReadingItemAtURL:url options:0 error:&error byAccessor:^(NSURL *newURL) {
NSData *data = [NSData dataWithContentsOfURL:newURL];
NSLog(@"error %@",error);
NSLog(@"data %@",data);
}];
[url stopAccessingSecurityScopedResource];
}发布于 2016-04-26 04:10:29
我认为从技术上讲,这些是目录(容器),这就是为什么.pdf可以工作,而.numbers不能工作,等等。
https://stackoverflow.com/questions/27643974
复制相似问题