在我的iOS应用程序中,如何从PhotoAlbum中获取所选图像,以及如何将其保存在应用程序文档目录中。
答案 0 :(得分:3)
-(void)showImagePicker
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
imagePicker.delegate = self;
[self presentModalViewController:imagePicker animated:YES];
}
现在使用以下委托方法处理用户选择的图像
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];//Do whatever you want to do with your image.
}
如果需要更加明智,请完成this tutorial
希望这有帮助。