2012-05-23 79 views
1

可能重复:
access camera from uiwebview?iphone如何从UIWebView访问摄像头?

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

我使用上面的编码,但它不工作..

如何从网页视图打开相机 任何一个帮我。

谢谢

回答

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

编码快乐......

+0

从HTML页面我按下它附带的按钮到.m文件,所以我们使用uiwebview所以上面的编码是有用的,只有我们使用uiview .. –

+0

看到这篇文章我问这样http://stackoverflow.com/questions/2915881/access-camera-from-uiwebview但我试过,我有空页面相机的样本没有打开..任何想法? –