我尝试从UIImagePicker逐个上传这两个图片。 UIImagePicker适用于单张图像。通过UIImagePicker输入,我将这些照片上传到Web服务器。对于单个图像上传到Web服务器,其工作正常,但不是两个图像,一个图像节省两次。这是我第一次使用 UIImagePicker 。我不确切知道应该在哪里进行更改,以便上传两张图片。
- (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];
}
答案 0 :(得分:1)
您必须使用数组在拍摄照片的每次点击中添加图像,因为图像选择器一次只能获取一个图像,另一个选项您可以使用ELCAlbumPicker选择多个图像并将这些图像添加到数组上并使用它们。