匹克的UIImagePickerController图像多(UIImagePickerControl

2019-08-02 00:33发布

我想简单地使使用的UIImagePickerController从photolibrary挑选多张图像,我希望我可以在照片选择器的底部添加一个子视图所以它看起来像这样的应用程序的功能:

它有一个简单的方法,你能做到吗? 我的代码目前仅弹出图像以标准的方式,但装载6个图像时,我只解雇控制器

最重要的还有,如果反正我可以一个小视图/工具栏添加到照片选择器视图,类似的例子一样,然后我可以做其他

    - (void)getMediaFromSource:(UIImagePickerControllerSourceType)sourceType{
      //get all available source types
      NSArray *mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:sourceType];

      //if source type available and supported media type is not null
      if ([UIImagePickerController isSourceTypeAvailable:sourceType
           && [mediaTypes count] > 0]) {

        UIImagePickerController *picker = [[UIImagePickerController alloc] init];
        //picker.mediaTypes = mediaTypes;   //allow videos
        picker.delegate = self;
        picker.sourceType = sourceType; //set source type to the given type

        /** WANT TO ADD A CUSTOM VIEW IN THE PHOTO PICKER VIEW **/

        [self presentViewController:picker animated:YES completion:nil];
      } else {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error accessing media"
                                                        message:@"Device doesn't support that media type"
                                                       delegate:nil
                                              cancelButtonTitle:@"Drat !"
                                              otherButtonTitles: nil];
        [alert show];
      }
    }

    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
      self.lastChosenMediaType = [info objectForKey:UIImagePickerControllerMediaType];  //record media type

      //if media type is image
      if ([lastChosenMediaType isEqual:(NSString *) kUTTypeImage]) {
        UIImage *chosenImage = [info objectForKey:UIImagePickerControllerOriginalImage];    //load image

        //save the image if is from camera shot
        if (imageOrVideoSourceType == UIImagePickerControllerSourceTypeCamera) {
          UIImageWriteToSavedPhotosAlbum (chosenImage, nil, nil , nil);
        }

        [images addObject:chosenImage]; //add to image list
        imageNum++;
      }

      changeImageOrVideo = true;

      if(imageNum >= 5){
          [picker dismissViewControllerAnimated:YES completion:nil];
      }
    }

Answer 1:

使用黑客像向上移位的UIImagePickerController和表示所选择的图像的主要原因下方是因为资产库替代方案将涉及被要求用户为访问位置由于围绕在照片拍摄是在图像元数据中的信息。

在iOS 6中询问用户是否要允许应用程序访问自己的照片(不是位置),你会被问到两个资源库的方法和途径的UIImagePickerController这个问题。

因此我认为,像上述黑客正在接近其效用结束。 下面是提供使用资产库中的多个图像的选择库中的链接还有其他的。



文章来源: UIImagePickerController Pick Multiple images