2012-05-23 77 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但我試過,我有空頁面相機的樣本沒有打開..任何想法? –