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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:51:34+00:00 2026-06-16T23:51:34+00:00

I have added a gesture recognizer (two finger tap) that detects when the user

  • 0

I have added a gesture recognizer (two finger tap) that detects when the user presses on an image in UIWebView and brings up a UIActivityViewController to save the image and other stuff. My problem is that when I press on an image there is a lag (depending on how big the image size may be) and what im trying to achieve is that when the user double taps on the image i want to show an activity indicator until the image is ready to be saved and etc… I may add that i think the problem is here ‘imageToBeSaved = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]];’ after i take out that code, there is no more lagging. Here’s my code:

// adding gesture recognizer to "website" (which is a "UIWebView")
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTap:)];
doubleTap.numberOfTouchesRequired = 2;
[website addGestureRecognizer:doubleTap];

// actions on gesture detect and call actionsOnImage for options
-(void) doubleTap :(UITapGestureRecognizer*) sender {
[loadingImageActivityIndicator startAnimating];
int scrollPositionY = [[self.website stringByEvaluatingJavaScriptFromString:@"window.pageYOffset"] intValue];
int scrollPositionX = [[self.website stringByEvaluatingJavaScriptFromString:@"window.pageXOffset"] intValue];

int displayWidth = [[self.website stringByEvaluatingJavaScriptFromString:@"window.outerWidth"] intValue];
CGFloat scale = website.frame.size.width / displayWidth;

CGPoint pt = [sender locationInView:self.website];
pt.x *= scale;
pt.y *= scale;
pt.x += scrollPositionX;
pt.y += scrollPositionY;

NSString *js = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).tagName", pt.x, pt.y];
NSString *tagName = [self.website stringByEvaluatingJavaScriptFromString:js];

if ([tagName compare:@"IMG" options:NSCaseInsensitiveSearch]==NSOrderedSame) {
    NSLog(@"tagName was IMG");
    NSString *imgURL = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).src", pt.x, pt.y];
    NSString *urlToSave = [self.website stringByEvaluatingJavaScriptFromString:imgURL];
    NSURL *url = [NSURL URLWithString:urlToSave];
    imageToBeSaved = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
    [website addSubview:loadingImageActivityIndicator];

    [self actionsOnImage];  // self made function with sharing capabilities (see below)
}

}

- (void) actionsOnImage {
[loadingImageActivityIndicator stopAnimating];

NSArray* dataToShare = [[NSArray alloc] initWithObjects:imageToBeSaved, nil];
UIActivityViewController* activityViewController =
[[UIActivityViewController alloc] initWithActivityItems:dataToShare
                                  applicationActivities:nil];
[self presentViewController:activityViewController animated:YES completion:^{}];
}
  • 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-06-16T23:51:36+00:00Added an answer on June 16, 2026 at 11:51 pm

    Perform loading of the image asynchronously. Rearrange your lines of code as follows

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),^{
         imageToBeSaved = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
         [self actionsOnImage];
    });
    
    [website addSubview:loadingImageActivityIndicator];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have added Long Tap gesture on UIWebView . But I want UIWebView to
I have added the following gesture recognizer to my user control: UIRotationGestureRecognizer *rotate =
In my app I have added the new Gesture Recognizers that are available in
I have added two swipe gesture recognizers (swipe left and swipe right) to my
I have added the following gesture recognizer: UIPanGestureRecognizer *d2 = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(ViewDragging2:)];
I have added two gesture recognizers to a view. One will handle the view
I have a UIScrollView containing a UIImageView. now I also added a two finger
I have a UITableView with a gesture recognizer added: UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc]
I have added a TextField to a UICell in order to allow a user
I have added a checker to ensure that all fields in a form 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.