iOS PHAssetResourceManager requestDataForAssetResource在设备中返回错误但在模拟器中有效

时间:2016-10-12 07:14:50

标签: ios objective-c ios9 phasset photokit

我曾尝试使用以下API,但如下所示出现此错误

错误域= NSCocoaErrorDomain代码= -1"(null)"

- (PHAssetResourceDataRequestID)requestDataForAssetResource:(PHAssetResource *)resource
                                                options:(nullable PHAssetResourceRequestOptions *)options
                                    dataReceivedHandler:(void (^)(NSData *data))handler
                                      completionHandler:(void(^)(NSError *__nullable error))completionHandler;

以下是示例实现

    NSArray *assetResourcesArray = [PHAssetResource assetResourcesForAsset: myPhAssetObject];
    PHAssetResource *assetResource = [assetResourcesArray objectAtIndex:0];

[[PHAssetResourceManager defaultManager] requestDataForAssetResource:assetResource options:nil dataReceivedHandler:^(NSData * _Nonnull data) {
    //do something with video data
    NSLog(@"data %lu", [data length]);
}
                                                   completionHandler:^(NSError * _Nullable error) {
                                                       NSLog(@"error ======== %@", error);
                                                   }];

任何正确方向的暗示都将受到高度赞赏。

0 个答案:

没有答案