本文主要是介绍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是空,需要再看看。
这篇关于Invalid parameter not satisfying: “assetUUID“的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!