【问题标题】:How to display 'Camera Roll' directly using ImagePickerController如何使用 ImagePickerController 直接显示“相机胶卷”
【发布时间】:2011-10-21 08:56:09
【问题描述】:

我想使用 imagePickerController 直接打开“相机胶卷”相册,而不是显示所有 3 个相册(相机胶卷、照片库、上次导入)。

有什么办法吗?

【问题讨论】:

  • 你试过设置imagepickercontroller的source type属性吗?

标签: ios camera uiimagepickercontroller photo-gallery


【解决方案1】:

使用

imagePickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

它会直接带你到相机胶卷。

【讨论】:

  • 这样他可以进入那个相册,但是不能返回去选择其他相册
【解决方案2】:

这样做很简单... 举个按钮的例子……你点击按钮然后尝试使用:

imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera; 

通过使用它,您将强制控制器使用相机。 .

[self presentModalViewController:imgPicker animated:YES]; 

imgPicker 是我的控制器的名称

【讨论】:

  • 相机不是相机胶卷
【解决方案3】:

要实现这一点,你只有一条路..

您可以创建 customImagePickerController 并在其中抓取显示所有相机胶卷图像。

为此,您可以使用 collectionview

否则

https://github.com/rahulmane91/CustomAlbumDemo

希望这对您有用。

感谢和问候 尼拉夫·扎拉瓦迪亚

【讨论】:

    【解决方案4】:

    利用照片框架

    @property(nonatomic , strong) PHFetchResult *assetsFetchResults;
         NSMutableArray *array;
    
        PHFetchOptions *fetchOptions = [[PHFetchOptions alloc] init];
        fetchOptions.predicate = [NSPredicate predicateWithFormat:@"title = %@", @"Custom Photo Album"];
        collection = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum
                                                              subtype:PHAssetCollectionSubtypeAny
                                                              options:fetchOptions].firstObject;
    
    _assetsFetchResults = [PHAsset fetchAssetsInAssetCollection:collection options:nil];
    

    使用上面的代码,把你想要获取数据的相册名称放在“自定义相册”的位置

    PHFetchResult *collectionResult = [PHAsset fetchAssetsInAssetCollection:collection options:nil];
    for (int h=0; h<[collectionResult count]; h++) {
        PHAsset *asset1 = collectionResult[h];   
        [_imageManager requestImageForAsset:asset1 targetSize:frame.size contentMode:PHImageContentModeAspectFill options:nil resultHandler:^(UIImage *result, NSDictionary *info)
         {
             [array2 addObject:result];
         }];
    }
    NSLog(@"array count%lu",(unsigned long)[array2 count]);
    

    在任何你想显示所有专辑图片的地方使用数组

    【讨论】:

    • 对不起,你也可以用 Swift 回答吗?
    【解决方案5】:

    您可以使用此代码直接访问

    imagePickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum
    

    但你必须有一个更好的用户界面

    试试这个同时提供凸轮和凸轮滚动的框架

    https://github.com/hyperoslo/ImagePicker https://github.com/hyperoslo/Gallery

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-04
      • 1970-01-01
      • 2020-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多