UIImagePickerControllerReferenceURL is missing

I am trying to get some data about the video that I selected in UIImagePicker.

So, when it gets into the delegate method UIImagePicker(below), I understand that I need to use the key UIImagePickerControllerReferenceURLfrom the information dictionary.

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    NSURL *url = [info objectForKey:UIImagePickerControllerReferenceURL];

    NSLog(@"%@",url);

    [library addAssetURL:[info objectForKey:UIImagePickerControllerReferenceURL] toAlbum:@"Compedia" withCompletionBlock:^(NSError *error) {
        if (error!=nil) {
            NSLog(@"Big error: %@", [error description]);
        }
    }];
}

The problem is that the url is obtained using nil. I printed a description of the information and looked like this:

Printing description of info:
{
    UIImagePickerControllerMediaType = "public.movie";
    UIImagePickerControllerMediaURL = "file://localhost/private/var/mobile/Applications/6630FBD3-1212-4ED0-BC3B-0C23AEEFB267/tmp/capture-T0x1f57e880.tmp.Ulfn5o/capturedvideo.MOV";
}

After doing some research, I found out that if I installed the camera with kUTTypeMovie, it should give me both the media and the link url.

Here is how I defined my camera:

cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
cameraUI.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, nil];
cameraUI.allowsEditing = YES;
cameraUI.delegate = delegate;
cameraUI.showsCameraControls = NO;
cameraUI.cameraOverlayView = [self getCustomToolBar];

Is there something I am missing?

Thank,

+5
source share
2 answers

. , , , , UIImagePickerControllerReferenceURL .

, , , UIImagePickerControllerReferenceURL , , UIImagePickerControllerReferenceURL. , .

, - ALAssetLibrary, , URL-.

:

PickerController sourceType, , photosLibrary/savedPhotosAlbum. , writeImageToSavedPhotosAlbum: orientation: completionBlock: URL .

, , , photosLibrary, savedPhotosAlbum, [info objectForKey:UIImagePickerControllerReferenceURL] url

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{

//dismiss the imagepicker view
[self dismissViewControllerAnimated:YES completion:nil];


if( [picker sourceType] == UIImagePickerControllerSourceTypeCamera )
{
    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
    ALAssetsLibrary *library = [Utils defaultAssetsLibrary];
    [library writeImageToSavedPhotosAlbum:image.CGImage orientation:(ALAssetOrientation)image.imageOrientation completionBlock:^(NSURL *assetURL, NSError *error )
     {
         //here is your URL : assetURL
     }];
}
else
{
    //else this is valid : [info objectForKey:UIImagePickerControllerReferenceURL]];
}

}

, .

+11

ALAssetsLibrary ... PHFetchOptions..

. : fooobar.com/questions/424444/...

0

All Articles