2017-04-25 8 views

답변

0

나는이 답변을 찾기가 어려웠으므로 앞으로 사람들을 돕기 위해 내장 된 iOS UIImagePickerController로 선택한 사진에 실제 파일 URL을 가져 오는 코드가 있습니다. ALAsset URL을 사용하여 PHAsset을 얻는 것에 대해 조금 불안해합니다. 다른 방법을 알고 있다면 꼭 공유하시기 바랍니다.

- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { 
NSURL* sourceURL = [info objectForKey:UIImagePickerControllerReferenceURL]; 
if (sourceURL != nil) { 
    PHAsset* asset = [[PHAsset fetchAssetsWithALAssetURLs:@[sourceURL] options:nil] lastObject]; 

    PHContentEditingInputRequestOptions* assetOptions = [[PHContentEditingInputRequestOptions alloc] init]; 
    [assetOptions setNetworkAccessAllowed:false]; 
    [asset requestContentEditingInputWithOptions:assetOptions 
     completionHandler:^(PHContentEditingInput* contentEditingInput, NSDictionary* info) { 
     NSURL* fullImageURL = contentEditingInput.fullSizeImageURL; 
     printf("Hey, got the actual image URL: %s\n", [[fullImageURL absoluteString] UTF8String]); 
     }]; 
    } 

// ...finish and dismiss the UIImagePickerController 
}