Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tamilanmanikandan opened this issue May 19, 2017 · 0 comments

Comments

@tamilanmanikandan
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant