当前位置:  开发笔记 > IOS > 正文

获取placeholderForCreatedAsset时,PHPhotoLibrary崩溃了

如何解决《获取placeholderForCreatedAsset时,PHPhotoLibrary崩溃了》经验,为你挑选了0个好方法。

我尝试使用以下代码将图像放入自定义相册:

PHAssetCollection *album = [self getMyAlbum];
UIImage *image = [self getMyImage];

[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
    PHAssetChangeRequest *createAssetRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:image];

    PHObjectPlaceholder * placeHolder = createAssetRequest.placeholderForCreatedAsset;

    PHAssetCollectionChangeRequest *albumChangeRequest = [PHAssetCollectionChangeRequest changeRequestForAssetCollection:album];

    if(placeHolder){
        [albumChangeRequest addAssets:@[ placeHolder ]];
    }

} completionHandler:^(BOOL success, NSError *error) {
    //doesen't matter
}];

因此,我在此行的用户日志中收到许多错误 createAssetRequest.placeholderForCreatedAsset

喜欢

1 CoreFoundation __exceptionPreprocess + 1245624

2 libobjc.A.dylib objc_exception_throw + 34136

3张照片__48- [PHChangeRequestHelper generateUUIDIfNecessary] _block_invoke + 116552

2 libdispatch.dylib _dispatch_semaphore_wait_slow + 79828

3张照片 - [PHChangeRequestHelper generateUUIDIfNecessary] + 115992

4张照片 - [PHAssetCreationRequest占位符ForCreatedAsset] + 244020

所以[PHChangeRequestHelper generateUUIDIfNecessary]让我崩溃

我只在iOS> 10上看到这个,我无法在模拟器中重现这一点.

它是什么?如何解决?

推荐阅读
oDavid_仔o_880
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有