1
我需要顯示Dropbox中所有照片的用戶列表,並提供使用它們的可能性(在項目中下載)。簡化用戶從他的相冊中挑選照片。 我正在使用Dropbox SDK v1.3.3。使用dropbox下載照片iOS SDK
UPDATE:
這是我迄今所做的:
- (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];
}
我讀了Dropbox API文檔。但我需要更多的東西,可以將它們保存在應用程序文件夾中並顯示給用戶。 – krotov
將文件下載到您的應用程序文件夾也包含在其API中。向下滾動到「下載文件」部分。然後顯示一張照片就像[yourImageView setImage:[UIImage imageNamed:@「MyDropBoxPhotos.jpg」]]; – Axeva