Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 820455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:28:35+00:00 2026-05-15T02:28:35+00:00

Is it possible to access iphone’s camera from uiwebview? I know phonegap does it,

  • 0

Is it possible to access iphone’s camera from uiwebview? I know phonegap does it, but how to make it work without phonegap?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T02:28:36+00:00Added an answer on May 15, 2026 at 2:28 am

    You can implement the UIWebView Delegate and intercept any attempted page load. By setting a custom url, you can pass a message to Objective C, that can launch the camera. To send data back to the web weiw you can initiate a new load (as I do in my example), or pass in some javascript using another method on UIWebView.

    Here is a working example, I just wrote:

        #import "WebViewCamAppDelegate.h"
        #import <UIKit/UIKit.h>
        @interface uiwebviewcameraAppDelegate : NSObject <UIApplicationDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate, UIWebViewDelegate> {
            UIWindow *window;
         UIViewController *viewController;
         UIWebView *webView; 
        }
    
        @property (nonatomic, retain) IBOutlet UIWindow *window;
    
        @end
    
    
        @implementation uiwebviewcameraAppDelegate
    
        @synthesize window;
    
        //This is the HTML we initially show in the WebView.  Note the url "showcamera:" is one I
        //invented with the intent to intercept it to show the camera.
        static NSString *htmlString = @"<br><A href=\"showcamera:\">Show Camera</a>";
    
    
        //Pretty Basic stuff.  We set the UIWebView Delegate so we can intercept the call and set up     //a ViewController so we can animate the UIImagePicker
        - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {     
         viewController = [[UIViewController alloc] init];
    
         webView = [[UIWebView alloc] initWithFrame:window.bounds];
         [webView loadHTMLString:htmlString baseURL:nil];
         webView.delegate = self;
    
         [viewController.view addSubview:webView];
         [window addSubview:viewController.view];
            [window makeKeyAndVisible];
         return YES;
        }
    
        //Note: I check to make sure the camera is available.  If it is not (iPod touch or Simulator) I show the photo library instead.
        -(void) showCamera {
         UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
         if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { 
          imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
         }
         else {
          imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
         }
         imagePicker.delegate = self;
         [viewController presentModalViewController:imagePicker animated:YES];
        }
    
        //Here we intercept any time the webview tries to load a document.  When the user hits our "showcamera: url" we go to work.
        - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
         if ([[[request URL] scheme] isEqualToString:@"showcamera"]) {
          [self showCamera];
          return NO;
         }
         return YES;
        }
    
        //After the imagepicker has done it's thing, we pass the data back to the webview to be displayed.
       //If we wanted to be fancy here, we could have done this via Javascript so we could dynamically insert an image without reloading the page.
        - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
         [viewController dismissModalViewControllerAnimated:YES];
         UIImage* image = [info objectForKey:UIImagePickerControllerOriginalImage];
         NSData *imageData = UIImageJPEGRepresentation (image, 0.5);
         [webView loadData:imageData MIMEType:@"image/jpeg" textEncodingName:@"UTF-8" baseURL:nil];
        }
    
    
        - (void)dealloc {
         [viewController release];
         [webView release];
            [window release];
            [super dealloc];
        }
    
        @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to access an element on a Master page from the page
Is it possible to access a USB drive or Flash card without using the
Is it possible to access hardware devices (web-cams, magnetic card readers, etc.) from within
Is it possible to access the Abstract Syntax Tree(AST) inside the javac.exe programmatically? Could
Is it possible to access a constant value (i.e. a public static final variable
Is it possible to get access to the spell checker that is incorporated in
Is it possible to directly access MySql databases through an Adobe AIR/Flex application? If
Is it possible to view an MS Access report in the .Net ReportViewer control?
Is it possible for subsonic to access dbo.sp_help_job?
Is it possible to mix all these access controls in one site? I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.