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

  • SEARCH
  • Home
  • 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 7082915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:06:49+00:00 2026-05-28T07:06:49+00:00

I have a UIWebView in which it has a UITapGestureRecognizer and basically in my

  • 0

I have a UIWebView in which it has a UITapGestureRecognizer and basically in my tap gesture recognizer I have:

- (CGPoint) pointsForImage:(UIGestureRecognizer *)sender
{
    CGPoint pt = [sender locationInView:self];

    NSString * offsetTop = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).offsetTop", pt.x, pt.y
                          ];

    NSString * offsetLeft = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).offsetLeft", pt.x, pt.y
                      ];

    NSString * scrollTop = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).parentNode.scrollTop", pt.x, pt.y
                              ];

    NSString * scrollLeft = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).parentNode.scrollLeft", pt.x, pt.y
                             ];


    float x = [[self stringByEvaluatingJavaScriptFromString:offsetTop] floatValue] - [[self stringByEvaluatingJavaScriptFromString:scrollTop] floatValue];
    float y = [[self stringByEvaluatingJavaScriptFromString:offsetLeft] floatValue] - [[self stringByEvaluatingJavaScriptFromString:scrollLeft] floatValue];

    CGPoint point = CGPointMake(x, y);
    return point;
}

basically what I am trying to do is find the top left x and y position of the image. Not relative to the UIWebView but to the content view. So say that the position of the image is 1000 pixels down, but I am now currently browsing the UIWebView down half way and therefore the number I want to see is 200. I hope this makes sense

  • 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-28T07:06:50+00:00Added an answer on May 28, 2026 at 7:06 am

    Actually UIWebView has a UIScrollView. You can access the UIScrollView in UIWebView using scrollView property. Then get the contentOffset of the scrollView. Finally, you got the contentOffset of the scrollView and the image position relative to the UIWebView, you can calculate the point you want.

    Try this piece of Javascript:

    stringByEvaluatingJavaScriptFromString below:

    function getPosition(element){
        var el = element;
        var pos = [el.offsetLeft, el.offsetTop];
        var parent = el.offsetParent;
        if (parent != el) { 
          while (parent) {  
            pos[0] += parent.offsetLeft; 
            pos[1] += parent.offsetTop; 
            parent = parent.offsetParent;
          }
        }
        return pos;
    }
    getPosition(YourImageElement);
    

    you’ll get the image position returned.

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

Sidebar

Related Questions

I have a UIWebView in my application which has links inside that when clicked
I have an iPad UIWebView which has to display some rtfd.zip files. I try
I have a UISplitViewController which has a UIWebView assigned to its detailedView. The problem
I have a UITextView which has a UIWebView just below it. The frame of
I have a UIViewController which is a UIWebViewDelegate and has a UIWebView inside of
I have a UIWebView which is loading a webpage. The webpage has a div-element
I have a view containing a UIWebView which is loading a google map (so
I have a UIWebView in my app which I want to use to display
I am trying to have a UI which is a full screen UIWebView. When
I have a UIWebView which inside a UIScrollView (scrollview contain another component) I tried

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.