How to display video from ALAsset to UICollectionview ios

会有一股神秘感。 提交于 2019-12-05 08:42:54

Replace this Line:-

              [allVideos addObject:dic];

With

              [allVideos addObject: asset];

And in this method:-

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

    NSLog(@"allvideo %@", allVideos);
    ALAsset *alasset = [allVideos objectAtIndex:indexPath.row];
    yourImageView.image = [UIImage imageWithCGImage:alasset.thumbnail];

 }

First of all take the code [_collectionView reloadData] out of the ALAssetsGroupEnumerationResultsBlock (the block you passed to -enumerateAssetsUsingBlock:) as it'll call the -reloadData for all the AVAssets found.

There is a sample app "MyImagePicker" available from apple which does the exact thing you want to do. You can study the working from there.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!