ELCImagePicker 学习总结(八)

来源:互联网 发布:汽车租赁源码 编辑:程序博客网 时间:2024/06/05 17:39

ELCImagePickerController.h

ELCImagePickerController.m

选取照片的属性设置已经事件的监听比如完成选择,取消选择。调用ELCAlbumPickerController来显示选择album的界面

  • elcPicker.maximumImagesCount = 3; //设置可以选择的最多的数量
  • elcPicker.returnsOriginalImage = YES; //返回全屏显示的image而不是fullResolutionImage
  • elcPicker.returnsImage = YES; //如果设置为yes就返回uiimage,如果是no,就仅仅返回asset location information.Return UIimage if YES. If NO, only return asset location information
  • elcPicker.onOrder = YES; //如果是yes就会在选择照片的时候显示顺序号码并且会按照选择的先后顺序来返回这个结果。For multiple image selection, display and return order of selected images, if set value to no, will not display the order number and the correct select order
  • elcPicker.mediaTypes = @[(NSString *)kUTTypeImage, (NSString *)kUTTypeMovie]; //设置支持的媒体类型Supports image and movie types,这样的话即便是video录制的也会将第一幅画面作为image来捕捉进来。如果只是选择的kUTTypeImage,那么就只会捕获真正的images

ELCAlbumPickerController.h

ELCAlbumPickerController.m

显示选择album相册界面(使用tableview设计)

  • Cancel button响应事件为elcImagePickerControllerDidCancel函数
  • 使用ALAssetsLibrary库来访问系统的资源文件
  • 利用ALAssetsGroup来获取相册详细信息(相册名称,照片数量,封面图片等)并且使用reloadTableView来刷新table view
  • assetFilter来给group设置assesfilter。包括allAssets, allVideos, allPhotos
  • numberOfAssets获取Get the number of assets in the group that match the filter 既为照片的数目
  • ALAssetsGroupPropertyName获取相册的名称
  • posterImage获取封面图片
  • resize将图片尺寸加以设定为显示的控件的大小


ELCAssetTablePicker.h

ELCAssetTablePicker.m

显示所有的照片集合


  • 使用tableview来实现显示
  • preparePhotos
  • self.columns来设置一共要显示的行数
  • self.elcAssets来保存所有的照片
  • 使用ELCAssetCell自定义cell来显示每一个单元格的内容
  • doneAction方法当完成照片的选择后点击done,会遍历所有的照片资源选出所有selected的资源,然后使用sortUsingSelector方法来进行数组的排序。然后将排序后的数组返回给selectedAssets方法来进行最后的将结果保存在returnArray中并且最终调用elcImagePickerController:didFinishPickingMediaWithInfo:返回结果
  • back后会[[ELCConsole mainConsole] removeAllIndex]移除所有的index


ELCAssetCell.h

ELCAssetCell.m

显示每张photo的可复用cell已经包含overlayview的设计

  • setAssets 来设置每个单元格的photo并将图片保存入 _imageViewArray中
  • 调用ELCOverlayImageView来为每一个photo添加一个Overlay.png,并保存入_overlayViewArray中
  • cellTapped响应cell的单击事件,设置cell当前的被选中的状态,根据当前选择的cell来获得对应的overlayview,并选择是显示还是不显示
  • 如果是selected的状态,调用parent的shouldSelectAsset方法(ELCAssetTablePicker.m)中,设置selectionCount目前为止选中的数量。然后调用shouldSelectAsset:previousCount来判断是否还可以继续选择照片,不能超过最大的设置的照片数量。如果超过了就提示用户无法进一步选择了。然后使用[[ELCConsole mainConsole] addIndex:asset.index]来添加需要选中的index
  • 如果是deselected的状态,嗲用parent的shouldDeselectAsset方法ELCAssetTablePicker.m)中,返回yes。调用assetDeselected方法ELCAssetTablePicker.m)中,将目前选中的selectedelements的数目去掉一个,调用方法[[ELCConsole mainConsole] removeIndex:lastElement]。


ELCAsset.h

ELCAsset.m

每一张photo的index,是否被选中,选中和未选中的状态的标识

  • 定义的协议
  • - (void)assetSelected:(ELCAsset *)asset;
    - (BOOL)shouldSelectAsset:(ELCAsset *)asset;
    - (void)assetDeselected:(ELCAsset *)asset;
    - (BOOL)shouldDeselectAsset:(ELCAsset *)asset;


ELCOverlayImageView.h

ELCOverlayImageView.m

每一个cell上的覆盖图,uiimageview的子类

  • labIndex 使用此label来显示选择的序号


ELCConsole.h

ELCConsole.m

管理所有的index

  • - (void)addIndex:(int)index;
    - (void)removeIndex:(int)index;
    - (int)currIndex;
    - (int)numOfSelectedElements;
    - (void)removeAllIndex;








0 0
原创粉丝点击