如何显示“相机胶卷”直接使用ImagePickerController

发布于 2024-12-11 10:09:03 字数 99 浏览 0 评论 0原文

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

有什么办法可以做到这一点吗?

I want to directly open the 'Camera Roll' album using the imagePickerController instead of showing all 3 albums (camera roll, photo library, last import).

Is there any way to do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

北城孤痞 2024-12-18 10:09:03

使用

imagePickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

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

Use

imagePickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

It will directly take you to camera roll.

呆橘 2024-12-18 10:09:03

做到这一点非常简单......
对于按钮的示例...您单击该按钮,然后尝试使用:

imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera; 

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

[self presentModalViewController:imgPicker animated:YES]; 

imgPicker 是我的控制器的名称

It is very simple to do that ...
For an example of a button ... You click on the button and then try to use :

imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera; 

By using that you will force the Controller to use the camera.
.

[self presentModalViewController:imgPicker animated:YES]; 

imgPicker is here the name of my controller

傻比既视感 2024-12-18 10:09:03

要实现这一点,你只有一个方法。

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

为此,您可以使用 collectionview

https://github.com/rahulmane91/CustomAlbumDemo

这可能有用给你。

谢谢&问候
尼拉夫·扎拉瓦迪亚

To achieve this you have only oneway..

You can create customImagePickerController and grab display all camera roll images in it.

For that you can use collectionview

or else

https://github.com/rahulmane91/CustomAlbumDemo

May this useful to you.

Thanks & Regards
Nirav Zalavadia

謌踐踏愛綪 2024-12-18 10:09:03

使用照片框架

@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]);

,并在你想要显示所有相册图像的任何地方使用该数组

make use of Photos Framework

@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];

Use the above code and put your album name whose data you want to Fetch in the place of "Custom Photo Album"

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]);

and use the array anywhere you want to display all albums images

唔猫 2024-12-18 10:09:03

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

imagePickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum

,但您必须有一个更好的 UI

尝试这个框架,它同时提供凸轮和凸轮滚动

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

Tou can use this code to access directly

imagePickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum

but you will have to have a better UI

Try this framework which gives both cam and cam roll

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文