ios - 在 IOS 的 ImageView 中显示多个图像

标签 ios objective-c image

我在我的项目中使用 ELCImagePickerController。通过它从图库中选择多个图像。我面临一个问题,如何在 View Controller 的 ImageView 中显示选定的多个图像。我创建了一个选择图像按钮,它将我们带到我们选择多张图像的照片库。我的代码是,

- (IBAction)Select:(id)sender {
    ELCImagePickerController *elcPicker = [[ELCImagePickerController alloc] initImagePicker];
    elcPicker.maximumImagesCount = 100; //Set the maximum number of images to select to 100
    elcPicker.returnsOriginalImage = YES; //Only return the fullScreenImage, not the fullResolutionImage
    elcPicker.returnsImage = YES; //Return UIimage if YES. If NO, only return asset location information
    elcPicker.onOrder = YES; //For multiple image selection, display and return  order of selected images
    // elcPicker.mediaTypes = @[(NSString *)kUTTypeImage, (NSString 

    *)kUTTypeMovie]; //Supports image and movie types

    elcPicker.imagePickerDelegate = self;

    [self presentViewController:elcPicker animated:YES completion:nil];

    }


    - (void)elcImagePickerController:(ELCImagePickerController *)picker 

    didFinishPickingMediaWithInfo:(NSArray *)info
    {
    [self dismissViewControllerAnimated:YES completion:nil];

    for (NSDictionary *dict in info)
    {
        if ([dict objectForKey:UIImagePickerControllerMediaType] == 
    ALAssetTypePhoto)
        {
            if ([dict objectForKey:UIImagePickerControllerOriginalImage])

            {
                UIImage* image=[dict 
    objectForKey:UIImagePickerControllerOriginalImage];

                 _arrimage.image;
            }
        }
    }

    }

    - (void)elcImagePickerControllerDidCancel:(ELCImagePickerController *)picker
    {

    [self dismissViewControllerAnimated:YES completion:nil];
}

最佳答案

您可以使用 CreolePhotoSelection获取并选择多个图像。它将帮助您获得多项选择并将所有选定的值检索到委托(delegate)方法中。

下面是它的示例代码:

CreolePhotoSelection *objCreolePhotoSelection= [[CreolePhotoSelection alloc] initWithNibName:@"CreolePhotoSelection" bundle:nil];
objCreolePhotoSelection.strTitle = YOUR_TITLE_FOR_PHOTO_VIEW;
objCreolePhotoSelection.delegate = self; // It will help to retrive all selected photos from CreolePhotoSelection
objCreolePhotoSelection.arySelectedPhoto = YOUR_CURRENT_ARRAY; // You need to pass same array which is holding selected image
objCreolePhotoSelection.maxCount = YOUR_MAX_PHOTOS_LIMIT; // Eg. 5, 10 anythings...

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:objCreolePhotoSelection];
[self.navigationController presentViewController:navController animated:YES completion:nil];

// Delegate Method
#pragma mark - Photo selected Delegate Method
-(void)getSelectedPhoto:(NSMutableArray *)aryPhoto
{
  // You will selected image array into aryPhoto object and you can use it
}   

关于ios - 在 IOS 的 ImageView 中显示多个图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45273309/

相关文章:

objective-c - 如何拆分一串单词并添加到数组中 - Objective C

iphone - 如何合并两个FBO?

ios - 在 UITextView 上采取有限的字符形式粘贴操作

javascript - Base64 SVG 图像

iphone - CoreText 绘图、接收触摸、触摸坐标困惑

ios - 使用 swift 创建 JSON

ios - 为 UITableViewCell 的 NSTextAttachment 异步加载图像

javascript - 在 Javascript 中显示图像的条件

javascript - 为什么我的图像没有在 HTML5 Canvas 上绘制?

ios - 如果我将 UUID 存储在钥匙串(keychain)中,iOS 应用商店批准是否有任何问题