Skip to content

how to implement ELCImagePickerController Delegate method in Swift 3.0? #139

@tamilanmanikandan

Description

@tamilanmanikandan
  • (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)];
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions