美文网首页
QBImagePicker 添加的图片

QBImagePicker 添加的图片

作者: 弗利撒 | 来源:发表于2017-11-27 09:55 被阅读0次

    时间是一切财富中最宝贵的财富。—— 德奥弗拉斯多


    今天分享下使用的一个小技巧:

    <PHAsset: 0x7feb5bd95e00>  9F983DBA-EC35-42B8-8773-B597CF782EDD/L0/001 mediaType=1/0, sourceType=1, (3000x2002), creationDate=2012-08-08 18:52:11 +0000, location=1, hidden=0, favorite=0

    上面是使用QBImagePicker选取一张图片后的详细信息。添加图片根据图片的基本信息存入一个数组,通过数组判断图片是否重复添加:

    - (void)qb_imagePickerController:(QBImagePickerController *)imagePickerController didFinishPickingAssets:(NSArray *)assets{

    if (imagePickerController.mediaType == QBImagePickerMediaTypeImage) {//判断是否是图片

    NSMutableArray *imageArray = [NSMutableArray array];

    for (PHAsset *set in assets) {

    NSString * str = set.description;//获取图片基本信息

    NSString * st = [str substringWithRange:NSMakeRange(26, 36)];//截取图片标识码进行存储识别

    if ([self.assets_array containsObject:st]) {// 包含图片

    } else { // 不包含

    [self.assets_array addObject:st];//self.assets_array 存储图片识别码

    PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init];

    options.synchronous = YES;

    options.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat;

    [[PHImageManager defaultManager] requestImageForAsset:set targetSize:[UIScreen mainScreen].bounds.size contentMode:PHImageContentModeAspectFit options:options resultHandler:^(UIImage *result, NSDictionary *info) { if (set.mediaSubtypes == PHAssetMediaSubtypePhotoLive) { //获取图片

    UIImage * image = [result scaleImageWithSize:CGSizeMake(1280, 960)];

    [imageArray addObject:image];

    } else {

    [imageArray addObject: result];

    }

    }];

    }

    }

    //进行自己的UI逻辑

    }

    }

    /**

    设置QBImagePiker

    @param modeType 存储类型

    @param promptStr 标识

    @param maxContent 最大选取数

    @param viewController

    */

    - (void) addQBImagePikerWithType:(QBImagePickerMediaType) modeType withPromt:(NSString * )promptStr withMax:(NSInteger) maxContent withViewController:(UIViewController *) viewController{

    QBImagePickerController * imagePickerIM = [QBImagePickerController new];

    imagePickerIM.delegate = viewController;

    imagePickerIM.mediaType = modeType;

    imagePickerIM.prompt = promptStr;

    imagePickerIM.showsNumberOfSelectedAssets = YES;

    imagePickerIM.allowsMultipleSelection = YES;

    imagePickerIM.maximumNumberOfSelection = maxContent;

    }

    今天比较忙写的不是很好,大家见谅!

    相关文章

      网友评论

          本文标题:QBImagePicker 添加的图片

          本文链接:https://www.haomeiwen.com/subject/rdrrbxtx.html