私のアプリケーションには、これらのコードを含む[参照]ボタンがあり、ユーザーはiPadのフォトギャラリーを参照し、写真を選択して、NSDocumentDirectoryを使用してアプリケーションに保存できます。
- (IBAction) BrowsePhoto:(id)sender
{
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:imagePickerController];
[popover setPopoverContentSize:CGSizeMake(320,320)];
[popover presentPopoverFromRect:CGRectMake(200,200,-100,-100) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
self.popoverController = popover;
[imagePickerController release];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)selectedImage editingInfo:(NSDictionary *)editingInfo
{
[self.popoverController dismissPopoverAnimated:YES];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [paths objectAtIndex:0];
NSString *savedImagePath = [documentsDir stringByAppendingPathComponent:@"SavedImage.png"];
UIImage *image = imageView.image;
NSData *imageData = UIImagePNGRepresentation(image);
[imageData writeToFile:savedImagePath atomically:NO];
}
ここで、NSDocumentDirectoryのすべての写真を新しいビューに表示する[表示]ボタンを含めたいと思います。サムネイルで表示することを考えていたのですが、画像をタップすると、選択した写真を削除するかどうかを確認するポップアップが表示されます。はいの場合、写真はNSDocumentDirectoryから削除されます。
これを行うことは可能ですか?もしそうなら、それを行う方法といくつかのサンプルコードを共有する方法を教えてください。私はまだプログラミングにかなり慣れていないので、私はかなり迷っています。