1

可能重复:
从 uiwebview 访问相机?

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;      
picker.allowsImageEditing = YES;      
picker.sourceType = UIImagePickerControllerSourceTypeCamera;       
[self presentModalViewController:picker animated:YES];
 return  NO;

我正在使用上面的编码,但它不起作用..

如何从 webview 打开相机任何人帮助我。

谢谢

4

1 回答 1

3

试试这个:

UIImagePickerController  *imgPicker = [[UIImagePickerController alloc] init];
imgPicker.delegate = self;
imgPicker.allowsImageEditing = YES;
imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:imgPicker animated:YES];
[imgPicker release];

下面是委托方法:

#pragma mark UIImagePickerController delegate
-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    // Access the uncropped image from info dictionary
    UIImage *imgCapturePhoto = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
    [self dismissModalViewControllerAnimated:YES];
}
-(void)imagePickerControllerDidCancel:(UIImagePickerController *) picker
{
    [picker dismissModalViewControllerAnimated:YES];
}

快乐的编码...

于 2012-05-23T12:20:53.883 回答