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 6096621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:56:58+00:00 2026-05-23T12:56:58+00:00

I’m currently developing a small, JavaScript based drawing application on iPad. I’ve simply wrapped

  • 0

I’m currently developing a small, JavaScript based drawing application on iPad. I’ve simply wrapped it inside UIWebView like this. Now the thing is that I can’t figure out how to save an image from the app so that it’s stored on iPad photos.

Is there some simple way to bridge JavaScript code with Objective-C one? I guess I could pass a string containing PNG image data from the JS side and then use Objective-C to save it to the photo gallery somehow.

  • 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-23T12:56:58+00:00Added an answer on May 23, 2026 at 12:56 pm

    Yes, there is a way to bridge javascript from a UIWebView to Obj-C code.

    Set your UIWebView delegate, and in your delegate paste in the following method

    //
    // Map links starting with file://
    //            ending with #action
    // with the action of the controller if it exists.
    //
    // Open other links in Safari.
    - (BOOL)webView: (UIWebView*)webView shouldStartLoadWithRequest: (NSURLRequest*)request navigationType: (UIWebViewNavigationType)navigationType {
        NSString *fragment, *scheme;
    
        if (navigationType == UIWebViewNavigationTypeLinkClicked) {
            [webView stopLoading];
            fragment = [[request URL] fragment];
            scheme = [[request URL] scheme];
    
            if ([scheme isEqualToString: @"file"] && [self respondsToSelector: NSSelectorFromString(fragment)]) {
                [self performSelector: NSSelectorFromString(fragment)];
                return NO;
            }
    
            [[UIApplication sharedApplication] openURL: [request URL]];
        }
    
        return YES;
    }
    

    Then you can write Obj-C methods that’ll handle the request. For example. In your webview you might have a button that has a link tag like

    <a href="file://myGreatApp.com/saveImage">Click Me to Save Image </a>
    

    The scheme is “file” the fragment is “saveImage”. You can now write an Obj-C method

    -(void)saveImage;
    

    That will be called every time a user clicks on the link.

    Edit:
    If you want to pass string parameters in your method, simply append them to your fragment url using javascript. So instead you might have

    <a href="file://myGreatApp.com/saveImage*asdgo8asdgl35lkjasgd807ll12">Click Me to Save Image </a>
    

    Then in your Obj-C code, split the fragment on the char ‘*’. Use the first half as your selector and the second half as the parameter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.