Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 为什么PHPhotoLibrary performChanges creationRequestForAssetFromVideoAtFileURL如此缓慢?_Ios_Swift_Mobile_Photokit - Fatal编程技术网

Ios 为什么PHPhotoLibrary performChanges creationRequestForAssetFromVideoAtFileURL如此缓慢?

Ios 为什么PHPhotoLibrary performChanges creationRequestForAssetFromVideoAtFileURL如此缓慢?,ios,swift,mobile,photokit,Ios,Swift,Mobile,Photokit,根据视频的大小,我测量的时间从几十秒到几分钟不等。这个更改请求不应该很快(本地闪存盘拷贝/元数据/校验和),因为它会将本地视频添加到photolibrary/相机卷中吗当iCloud备份打开时,似乎会出现此问题。我一直无法通过web搜索或apple dev文档找到很多有用的信息 示例代码: func exportAssetToPhotoLibrary(videoURL: NSURL, _ exportedAsset: (localIdentifier: String) -> Voi

根据视频的大小,我测量的时间从几十秒到几分钟不等。这个更改请求不应该很快(本地闪存盘拷贝/元数据/校验和),因为它会将本地视频添加到photolibrary/相机卷中吗当iCloud备份打开时,似乎会出现此问题。我一直无法通过web搜索或apple dev文档找到很多有用的信息

示例代码:

    func exportAssetToPhotoLibrary(videoURL: NSURL, _ exportedAsset: (localIdentifier: String) -> Void) {
        var localIdentifier = ""
        var startTime = NSDate.timeIntervalSinceReferenceDate()
        PHPhotoLibrary.sharedPhotoLibrary().performChanges({
            let assetRequest = PHAssetChangeRequest.creationRequestForAssetFromVideoAtFileURL(videoURL)
            let assetPlaceholder = assetRequest.placeholderForCreatedAsset
            localIdentifier = assetPlaceholder.localIdentifier
        },
        completionHandler: { success, error in
                var elapsedTime: NSTimeInterval = NSDate.timeIntervalSinceReferenceDate() - startTime
                NSLog("exported cameo video to photo library \(elapsedTime)")
                exportedAsset(localIdentifier: localIdentifier)
        })
    }