xcode 如何处理来自 UIImagePickerController 的多个图像?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7867872/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to handle multiple images from UIImagePickerController?
提问by Gavy
I'm relatively new to XCode and I don't understand how to allow the user to pick multiple images from the UIImagePickerControler. This is my current code that allows the user to pick one image:
我对 XCode 比较陌生,我不明白如何允许用户从 UIImagePickerControler 中选择多个图像。这是我当前允许用户选择一张图像的代码:
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
Then, to process the image selected, I use:
然后,为了处理选择的图像,我使用:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[self dismissModalViewControllerAnimated:YES];
UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage];
//do stuff with image
}
How do I modify both parts of the code to allow the user to pick more than one image. Thanks in advance.
如何修改代码的两部分以允许用户选择多个图像。提前致谢。
Guvvy
古维
采纳答案by TheEye
The UIImagePickerController does not have an API for multiple image picking afaik - but this might give you a start: http://www.iphonedevsdk.com/forum/iphone-sdk-development/55351-uiimagepickercontroller-multi-select-photos.html
UIImagePickerController 没有用于多个图像选择 afaik 的 API - 但这可能会让您开始:http: //www.iphonedevsdk.com/forum/iphone-sdk-development/55351-uiimagepickercontroller-multi-select-photos.html
回答by zakishaheen
Look into the Asset Library APIs. They let you do what ImagePicker does internally. You can then add on top of that your own logic (i.e. multiselect). Here's a nice tutorial for that.
查看资产库 API。他们让你做 ImagePicker 在内部做的事情。然后您可以添加您自己的逻辑(即多选)。 这是一个很好的教程。
回答by Oscar Gomez
Unfortunately you will have to build your custom interface for this to work.
不幸的是,您必须构建自定义界面才能使其正常工作。