问题描述
我试图只使用 UIImagePickerController
从影像库中选择多个图像。我对 XCode 我不明白如何允许用户从
UIImagePickerControler
中选择多个图像。这是我目前的代码。请帮助任何人如何从 UIImagePickerController
中选择多个图像。
I am trying to simply enable picking multiple images from photolibrary using the
UIImagePickerController
.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.Please help any body how to pick multiple images from UIImagePickerController
.
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch(buttonIndex)
{
case 0:
[self takeNewPhotoFromCamera];
break;
case 1:
[self choosePhotoFromExistingImages];
default:
break;
}
}
- (void)takeNewPhotoFromCamera
{
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera])
{
UIImagePickerController *controller = [[UIImagePickerController alloc] init];
controller.sourceType = UIImagePickerControllerSourceTypeCamera;
controller.allowsEditing = NO;
controller.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:
UIImagePickerControllerSourceTypeCamera];
controller.delegate = self;
[self.navigationController presentViewController: controller animated: YES completion: nil];
}
}
-(void)choosePhotoFromExistingImages
{
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypePhotoLibrary])
{
UIImagePickerController *controller = [[UIImagePickerController alloc] init];
controller.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
controller.allowsEditing = NO;
controller.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:
UIImagePickerControllerSourceTypePhotoLibrary];
controller.delegate = self;
[self.navigationController presentViewController: controller animated: YES completion: nil];
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[self.navigationController dismissViewControllerAnimated: YES completion: nil];
UIImage *image = [info valueForKey: UIImagePickerControllerOriginalImage];
NSData *imageData = UIImageJPEGRepresentation(image, 0.1);
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker;
{
[self.navigationController dismissViewControllerAnimated: YES completion: nil];
}
推荐答案
带
UIImagePickerController
你只能得到一张照片。如果您需要选择更多,则需要自定义图像选择器,例如 ELCImagePickerController 。它运作良好!您可以下载它。
With
UIImagePickerController
you are able to get only one picture. If you need to pick more you need a custom image picker, such as ELCImagePickerController. It works well! You can download it here.
这篇关于如何从ios中的UIImagePickerController中选择多个图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!