“imagePickerController:didFinishPickingMediaWithInfo:” “UIImagePickerControllerMediaURL”信息字典中的关键奇怪行为

发布于 2024-10-09 21:11:39 字数 576 浏览 0 评论 0原文

在“imagePickerController:didFinishPickingMediaWithInfo:”中,信息字典有时没有键“UIImagePickerControllerMediaURL”。有时确实有。我尝试清洁目标,但这没有帮助。此外,工作流程始终相同:我遵循相同的步骤并从库中选择相同的视频文件。有时信息字典中包含“UIImagePickerControllerMediaURL”键,有时同一文件的信息字典本身中不存在“UIImagePickerControllerMediaURL”。无法理解。有人可以帮忙吗?

这是我从照片库中选择视频/电影时的信息字典的 NSLog

info dict = {
    UIImagePickerControllerMediaType = "public.movie";
    UIImagePickerControllerReferenceURL = "assets-library://asset/asset.MOV?id=1000000466&ext=MOV";
} 

In "imagePickerController:didFinishPickingMediaWithInfo:" the info dictionary sometimes doesn't have the key "UIImagePickerControllerMediaURL". Sometimes it does have. I tried cleaning the targets but that didn't help. Also, the workflow is always the same: I follow the same steps and choose the same video file from library. Sometime info dictionary has "UIImagePickerControllerMediaURL" key in it and sometime "UIImagePickerControllerMediaURL" is absent in the info dictionary itself for the same file. Could not understand it. Can somebody help ?

This is my NSLog of info dictionary when i select video/movie from photos library :

info dict = {
    UIImagePickerControllerMediaType = "public.movie";
    UIImagePickerControllerReferenceURL = "assets-library://asset/asset.MOV?id=1000000466&ext=MOV";
} 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

断爱 2024-10-16 21:11:39
- (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];

}
- (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];

}
征﹌骨岁月お 2024-10-16 21:11:39

当您的帐户视频保存在 iCloud 上时,就会发生这种情况。当您选择视频时,它会暂时从 icloud 下载并显示给您,因此 UIImagePickerControllerMediaURL 将不会出现。

It happen when your account Video save on iCloud. When you choose video it will temporarily download from icloud and show to you so UIImagePickerControllerMediaURL will don't appear.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文