ios - 相册中所有视频的 NSURL

标签 ios iphone objective-c

我正在尝试制作一个自定义应用程序,我想在其中将用户相册中的所有用户视频显示到 UITableView 中。我遇到的问题是我不知道如何访问所有视频 NSURL。一旦我有了它们,我就可以将它们放入 NSArray 中,并从它们中的每一个创建一个图像并将它们放入表中。我正在尝试做与此应用程序中类似的事情。有什么建议吗?

请注意,我熟悉 UIImagePickerController 在弹出 View Controller 中显示图像。这不是我想要的。

enter image description here

最佳答案

试试这个

首先添加AssetsLibrary.framework

#import <AssetsLibrary/AssetsLibrary.h>

然后

ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop)
 {
     [group enumerateAssetsUsingBlock:^(ALAsset *alAsset, NSUInteger index, BOOL *innerStop)
      {
          if (alAsset)
          {
              ALAssetRepresentation *representation =[alAsset defaultRepresentation];
              NSURL *url = [representation url];
              NSString *assetType=[alAsset valueForProperty:ALAssetPropertyType];
              UIImage *thumbNailImage=[UIImage imageWithCGImage:alAsset.thumbnail];
          }
      }];
     if(group==nil)
     {
         // do what ever if group getting null
     }
 } failureBlock: ^(NSError *error)
 {
     // may be photo privacy setting disabled
 }
 ];

关于ios - 相册中所有视频的 NSURL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20019960/

相关文章:

ios - 如何在 iPhone 上退出 Google+

ios - 如何在 IOS Swift 中检测飞行模式/飞行模式

ios - 神奇记录iOS最新版本是2.2

iphone - 包含新启动画面时非 4 英寸应用程序顶部对齐

iphone - 从横向开始的 Uiwebview 无法正确调整为纵向,但从纵向开始一切正常

ios - 在 iPhone 应用程序中检测通话状态?

objective-c - 正确使用 CIDetectorTracking

objective-c - 将字符串转换为日期会损失一个小时

ios - 将整个文本字段添加到 UITableView 以自动填充

ios - .class :hover . otherClass {...} - iOS Safari 不工作