Msgstr "Image:

In the " imagePickerController:didFinishPickingMediaWithInfo: " information dictionary sometimes does not have the key " UIImagePickerControllerMediaURL ". Sometimes it happens. I tried to clear the goals, but that didn't help. In addition, the workflow is always the same: I follow the same steps and select the same video file from the library. In some information dictionary there is a key " UIImagePickerControllerMediaURL ", and sometimes " UIImagePickerControllerMediaURL " is missing in the information dictionary for the same file. I could not understand this. Can anyone help?

This is my NSLog information dictionary when I select a video / movie from the photo library:

 info dict = { UIImagePickerControllerMediaType = "public.movie"; UIImagePickerControllerReferenceURL = "assets-library://asset/asset.MOV?id=1000000466&ext=MOV"; } 
+4
source share
2 answers
 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { NSMutableDictionary *infoDict = [[NSMutableDictionary alloc]init]; NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType]; if ([mediaType isEqualToString:@"public.image"]){ UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"" message:@"You Select a image Please select Movie" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [myAlertView show]; [myAlertView release]; } else if ([mediaType isEqualToString:@"public.movie"]){ NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL]; mAppDelegate.uploadType = @"Video"; NSData *webData = [NSData dataWithContentsOfURL:videoURL]; [infoDict setValue:webData forKey:@"VideoUrl"]; [infoDict setValue:[[mAppDelegate.userInfoArray objectAtIndex:1]valueForKey:@"user_id"] forKey:@"user_id"]; [[WakeUpParsing sharedInstance] assignSender:self]; [[WakeUpParsing sharedInstance] startParsingForVedioUploade:infoDict]; } [picker dismissModalViewControllerAnimated:YES]; [infoDict release]; } - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { // Dismiss the image selection and close the program [[picker parentViewController] dismissModalViewControllerAnimated:YES]; } 
+4
source

This happens when your account saves the video to iCloud. When you select a video, it will temporarily load from icloud and show you, so the UIImagePickerControllerMediaURL will not appear.

0
source

Source: https://habr.com/ru/post/1333781/


All Articles