我正在尝试获取有关我在UIImagePicker
.
因此,当它进入UIImagePicker
委托方法(如下)时,我知道我需要使用UIImagePickerControllerReferenceURL
信息字典中的密钥。
-(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]);
}
}];
}
问题是 url 的结果是 nil。我打印了信息的描述,它看起来像这样:
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";
}
在我做了一些研究之后,我发现如果我用kUTTypeMovie
它设置相机应该给我媒体和参考网址。
这就是我定义我的相机的方式:
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];
有什么我想念的吗?
谢谢,