samedi 9 mai 2015

How to Select multiple images and Video from camera roll objective c?

i try to select multiple images and multiple videos,image multiple selection is working properly and uploading properly ,am using ELCImagePickerController ,but when i click on video that also returns image file . So please help ma as soon as fast.so am posting that code also here

     - (void)elcImagePickerController:(ELCImagePickerController *)picker didFinishPickingMediaWithInfo:(NSArray *)info
     {
    [self dismissViewControllerAnimated:YES completion:nil];

for (UIView *v in [_scrollView subviews]) {
    [v removeFromSuperview];
}

CGRect workingFrame = _scrollView.frame;
workingFrame.origin.x = 0;

NSMutableArray *images = [NSMutableArray arrayWithCapacity:[info count]];
for (NSDictionary *dict in info) {
    if ([dict objectForKey:UIImagePickerControllerMediaType] == ALAssetTypePhoto){
        if ([dict objectForKey:UIImagePickerControllerOriginalImage]){
            UIImage* image=[dict objectForKey:UIImagePickerControllerOriginalImage];
            [images addObject:image];

            UIImageView *imageview = [[UIImageView alloc] initWithImage:image];
            [imageview setContentMode:UIViewContentModeScaleAspectFit];
            imageview.frame = workingFrame;

            [_scrollView addSubview:imageview];

            workingFrame.origin.x = workingFrame.origin.x + workingFrame.size.width;
        } else {
            NSLog(@"UIImagePickerControllerReferenceURL = %@", dict);
        }
    } else if ([dict objectForKey:UIImagePickerControllerMediaType] == ALAssetTypeVideo){
        if ([dict objectForKey:UIImagePickerControllerOriginalImage]){
            UIImage* image=[dict objectForKey:UIImagePickerControllerOriginalImage];

            [images addObject:image];

            UIImageView *imageview = [[UIImageView alloc] initWithImage:image];
            [imageview setContentMode:UIViewContentModeScaleAspectFit];
            imageview.frame = workingFrame;

            [_scrollView addSubview:imageview];

            workingFrame.origin.x = workingFrame.origin.x + workingFrame.size.width;
        } else {
            NSLog(@"UIImagePickerControllerReferenceURL = %@", dict);
        }
    } else {
        NSLog(@"Uknown asset type");
    }
}

self.chosenImages = images;

[_scrollView setPagingEnabled:YES];
[_scrollView setContentSize:CGSizeMake(workingFrame.origin.x, workingFrame.size.height)];

}

Aucun commentaire:

Enregistrer un commentaire