0

I tried to upload the two images one by one from UIImagePicker. UIImagePicker working good for single image. With UIImagePicker input i uploaded those photos into web server. For single image uploading into web server its working fine, But instead of two images one image is saving two times. This is the first time I am working on UIImagePicker. I don't know exactly where should I do changes to make it for uploading two images.

  - (void)takePhoto:(UIButton *)sender {


if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {

    UIAlertView   *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
                                                          message:@"Device has no camera"
                                                         delegate:nil
                                                cancelButtonTitle:@"OK"
                                                otherButtonTitles: nil];

    [alertView show];

}

else{

    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.allowsEditing = YES;
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    [self presentViewController:picker animated:YES completion:NULL];



}


}
- (void)selectPhoto:(UIButton *)sender {

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:NULL];

}



- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

chosenImage = info[UIImagePickerControllerEditedImage];
chosenImage1=info[UIImagePickerControllerEditedImage];
chosenImage2=info[UIImagePickerControllerEditedImage];

imageView.image = chosenImage;

frstCmpImgView.image= chosenImage1;
scndCmpImgView.image=chosenImage2;


if ([self.navigationItem.title  isEqual: @"CLOTHING"]) {
    NSLog(@"cloth page");
    [self clothview];
}
else if([self.navigationItem.title  isEqual: @"FACE PHOTO"]){


    [self hideButtns];

    NSLog(@"face page");

}

else{
    //----compare object--

    if ([cmparObjLabel.text isEqualToString:@"Choose the 1st Object"]) {
        [self afterUploadFrstCmpObj];

    }
    else if ([cmparObjLabel.text isEqualToString:@"Choose the 2nd Object"])
    {

        [self afterUploadScndCmpObj];
    }
}
[picker dismissViewControllerAnimated:YES completion:NULL];

}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {

[picker dismissViewControllerAnimated:YES completion:NULL];

}
Code cracker
  • 3,105
  • 6
  • 37
  • 67

1 Answers1

1

You have to use array for adding image in each and every click of take photo because image picker only fetch image one at a time , another option You can user ELCAlbumPicker to select multiple image and add these image over array and use them.

S_S
  • 9
  • 3