gpt4 book ai didi

ios - 将相机胶卷照片获取到自定义收藏 View

转载 作者:搜寻专家 更新时间:2023-10-30 20:17:55 24 4
gpt4 key购买 nike

我有一个带有单元格的自定义 Collection View 。这是我的 CollectionView 代码。

- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath;
{
Cell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"MY_CELL" forIndexPath:indexPath];

return cell;
}

我想从相机胶卷中获取图像并显示在这些单元格中。我怎样才能在这个单元格中查看相机胶卷图像?我应该使用数组来存储图像的名称然后在 Cell 中显示它们吗?谁能给我一个带有代码的解决方案。

最佳答案

您可以使用 <AssetsLibrary/AssetsLibrary.h> 获取相册和照片/视频资源框架:

-(void)getAlbum
{
library = [[ALAssetsLibrary alloc] init];
ALAssetsLibraryGroupsEnumerationResultsBlock listGroupBlock = ^(ALAssetsGroup *group, BOOL *stop) {

if (group)
{
[_albumsArray addObject:group];
} else {
[self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
}
};

[library enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:listGroupBlock failureBlock:failureBlock]
}

选择相册时,您将通过以下方法获取照片/视频

-(void)getAssets
{
ALAssetsGroupEnumerationResultsBlock assetsEnumerationBlock = ^(ALAsset * result, NSUInteger index, BOOL *stop) {

if (result)
{

}
else
{
[self.tableView reloadData];
}
};

[_assetGroup setAssetsFilter:[ALAssetsFilter allAssets]];

[_assetGroup enumerateAssetsUsingBlock:assetsEnumerationBlock];
}

请引用这个link有关 TableView 的更多信息和示例。另外,您可以用 UICollectionView 替换表格 View

谢谢!

关于ios - 将相机胶卷照片获取到自定义收藏 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22575568/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com