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

时间:2010-12-30 11:35:20

标签: ios objective-c uiimagepickercontroller

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

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

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

2 个答案:

答案 0 :(得分:4)

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

}

答案 1 :(得分:0)

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