1

UIImages複数の動画を選択しようとしていますが、画像の複数選択が機能しており、適切にアップロードされています。を使用しELCImagePickerControllerていますが、ビデオをタップすると、画像ファイルも返されます。これが私のコードです:

- (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)];
}
4

0 に答える 0