Invalid parameter not satisfying: “assetUUID“

问题:加载相册->退出相册->加载相册,第二次加载相册的时候,调用下面这个方法,用不到asset.localIdentifier, 但是报标题的错

- (PHImageRequestID)requestImageForAsset:(PHAsset *)asset targetSize:(CGSize)targetSize contentMode:(PHImageContentMode)contentMode options:(PHImageRequestOptions *)options resultHandler:(void (^)(UIImage *result, NSDictionary *info))resultHandler;

原因:传的asset是空,所以得不到asset.localIdentifier。代码中先调用了我的collectionView:cellForItemAtIndexPath:加载cell,但是我用的数据中asset还没有执行到更新的地方,所以加载的cell传参数asset是空

解决方法:album asset数组已经非空的条件下,collectionView:cellForItemAtIndexPath:直接获取asset数据,而不是通过self.xx去获取,避免"得到非空数组 -> 访问还没有更新的self.xx -> cell传参数asset是空"

- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    TempCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kTempCellIdetifier forIndexPath:indexPath];

    NSArray<PHAsset *> *assetArray = [TempData.sharedInstance fetchPHAsset];
    [cell updateForImage: assetArray[indexPath.item]];

     return cell;
}

不重要的:怎么让album asset数组非空?用PHPhotoLibraryChangeObserver这个协议,当授予权限后并且registerChangeObserver: ,用户授权后相册调用PHPhotoLibraryChangeObserver协议的方法,通过delegate让需要更新相册的对象reload collectionView

如果不是我这种情况,据说有的情况asset非空,localIdentifier是空,需要再看看。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值