• 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是空"

    1. - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    2. TempCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kTempCellIdetifier forIndexPath:indexPath];
    3. NSArray<PHAsset *> *assetArray = [TempData.sharedInstance fetchPHAsset];
    4. [cell updateForImage: assetArray[indexPath.item]];
    5. return cell;
    6. }

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

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

  • 相关阅读:
    传输层:TCP和UDP
    基于 Bresenham 算法画圆
    【漏洞复现】panalog日志审计系统任意用户创建漏洞和后台命令执行
    部分准备金银行已经过时
    中文Stable Diffusion模型太乙使用教程
    位运算相关笔记
    无障碍阅读他人开源项目结构:看完本文,你将信心满满
    【网络】网络扫盲篇 ——用简单语言和图解带你入门网络
    72编辑距离
    从模型容量的视角看监督学习
  • 原文地址:https://blog.csdn.net/qq_41961638/article/details/133773807