相册多选 YSHYAssetsPickerDemo

GPL
Objective-C
跨平台
2017-02-09
yangshuyuan

相册多选功能实现,在需要调用相册的地方,添加如下代码即可:

    YSHYAssetPickerController *picker = [[YSHYAssetPickerController alloc]initWithNumber:5 andHasSelectedImags:dataSource];//最多只能选5张 并传入已经选好的图片数组
    picker.assetsFilter = [ALAssetsFilter allPhotos];

    picker.showEmptyGroups = NO;

    picker.pickerDelegate = self;

    picker.selectionFilter = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject,NSDictionary *bindings){
        if ([[(ALAsset *)evaluatedObject valueForProperty:ALAssetPropertyType]isEqual:ALAssetTypeVideo]) {
            NSTimeInterval duration = [[(ALAsset *)evaluatedObject valueForProperty:ALAssetPropertyDuration]doubleValue];
            return duration >= 5;
        }else{
            return  YES;
        }
    }];

    [self presentViewController:picker animated:YES completion:^{
    }];

实现其代理方法:

-(void)assetPickerController:(YSHYAssetPickerController *)picker didFinishPickingAssets:(NSArray *)assets {

 [dataSource removeAllObjects];

 [dataSource addObjectsFromArray:assets];

  [self CreatImageViewWithImags:dataSource];

}

加载中

评论(0)

暂无评论

暂无资讯

暂无问答

暂无博客

返回顶部
顶部