我需要向用户显示 Dropbox 中所有照片的列表,并提供使用它们的可能性(在项目中下载)。像用户从他的相册中挑选照片一样简化。我正在使用 Dropbox SDK v1.3.3。
更新:
这是我到目前为止所做的:
- (void)restClient:(DBRestClient *)client loadedMetadata:(DBMetadata *)metadata {
if (metadata.isDirectory) {
// Available files extensions
NSArray *validExtensions = [NSArray arrayWithObjects:@"jpg", @"jpeg", @"png", nil];
// Local path
NSArray *libraryPaths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
NSString *LibraryDirectory = [libraryPaths objectAtIndex:0];
LibraryDirectory = [LibraryDirectory stringByAppendingString:@"/Dropbox/"];
NSString *localPath = @"";
if (![[NSFileManager defaultManager] fileExistsAtPath:LibraryDirectory]){
NSError* error;
if( [[NSFileManager defaultManager] createDirectoryAtPath:LibraryDirectory withIntermediateDirectories:NO attributes:nil error:&error])
;// success
else {
NSLog(@"[%@] ERROR: attempting to write create Dropbox directory", [self class]);
NSAssert( FALSE, @"Failed to create directory maybe out of disk space?");
}
}
// Work with dropbox files array
for (DBMetadata *file in metadata.contents) {
NSString* extension = [[file.path pathExtension] lowercaseString];
if(![file isDirectory] && [validExtensions indexOfObject:extension]!=NSNotFound) {
localPath = [LibraryDirectory stringByAppendingPathComponent:[file filename]];
// Add file to Dropbox Directory
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:localPath];
if(!fileExists) [[self restClient] loadFile:file.path intoPath:localPath];
}
}
}
}
刚刚离开显示来自 Dropbox 本地文件夹的照片列表。也许有人知道该怎么做?我希望它像相册中的那样:
- (void)getDropboxPhotoList:(NSString *)path {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
/* source must be not from gallery, but from local folder */
//imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.delegate = self;
UIPopoverController *pop = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
[pop presentPopoverFromBarButtonItem:(UIBarButtonItem *)dropboxButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
popover = pop;
[imagePicker release];
}