zoukankan      html  css  js  c++  java
  • iOS中图片与视频一次性多选

     

    http://www.cnblogs.com/v2m_/archive/2012/12/21/2827324.html

    一.使用系统的Assets Library Framework
    这个是用来访问Photos程序中的图片和视频的库。其中几个类解释如下
      ALAsset
        ->包含一个图片或视频的各种信息

      ALAssetRepresentation
        ->得到ALAsset的各种信息

      ALAssetsFilter
        ->用来从一个ALAssetsGroup中检索ALAssets

      ALAssetsGroup
        ->一组ALAsset,一个asset可以属于多个这样的组,可以添加一个asset到某个组中

      ALAssetsLibrary
        ->整个图片库中的内容,可以对图片库的获取与编辑等

      网上有人说这种方法会要求授权地理位置信息,不过我没有遇到...

    看看官方的使用示例,枚举的时候以nil结束哦,记得判断处理下。

    复制代码
    // The following example shows how you can get an asset to represent the first video in the Saved Photos Album.
    
    ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
    
    // Enumerate just the photos and videos group by using ALAssetsGroupSavedPhotos.
    [library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
    
    // Within the group enumeration block, filter to enumerate just videos.
    [group setAssetsFilter:[ALAssetsFilter allVideos]];
    
    // For this example, we're only interested in the first item.
    [group enumerateAssetsAtIndexes:[NSIndexSet indexSetWithIndex:0]
    options:0
    usingBlock:^(ALAsset *alAsset, NSUInteger index, BOOL *innerStop) {
    
    // The end of the enumeration is signaled by asset == nil.
    if (alAsset) {
    ALAssetRepresentation *representation = [alAsset defaultRepresentation];
    NSURL *url = [representation url];
    AVAsset *avAsset = [AVURLAsset URLAssetWithURL:url options:nil];
    // Do something interesting with the AV asset.
    }
    }];
    }
    failureBlock: ^(NSError *error) {
    // Typically you should handle an error more gracefully than this.
    NSLog(@"No groups");
    }];
    
    [library release];
    复制代码

    二.网络上的另一种方法-MHImagePickerMutilSelector
    这个是通过设置 UINavigationControllerDelegate的方法,当UIImagePickerController显示在界面上的时候,判断一下 当前是图集列表(相当于AlAssetsGroup的列表)还是图片列表(相当于AlAsset的列表),如果是图片列表就调整scrollview的大 小,并在下面加上一个自己的滚动视图用来显示已经选择的图片。

    这个方法的缺点是对已经选择的图片做点自定义的动作相对而言比较麻烦。

    我稍微修改了下^_^(仅仅是稍微,让它调用的时候简单了点,对重复图片什么的也没有处理)

    使用时只要UIVIewController实现了 MHImagePickerMutilSelector的协议,然后这样调用就好了。

    [MHImagePickerMutilSelector showInViewController:self];

    这里下载。

    参考:http://www.cocoachina.com/bbs/read.php?tid=112242

  • 相关阅读:
    54:代码审计-TP5框架审计写法分析及代码追踪
    53:代码审计-TP5框架及无框架变量覆盖反序列化
    52:代码审计-PHP项目类RCE及文件包含下载删除
    51:代码审计-PHP框架MVC类上传断点调试挖掘
    支配树学习笔记
    模拟费用流学习笔记
    python之元类、双下方法( 双下方法也叫魔术方法、 内置方法)
    java 注解
    java 反射
    java synchronized
  • 原文地址:https://www.cnblogs.com/allanliu/p/4210996.html
Copyright © 2011-2022 走看看