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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:25:50+00:00 2026-05-23T07:25:50+00:00

I am trying to attach a UITapGestureRecognizer to a webview that i am creating

  • 0

I am trying to attach a UITapGestureRecognizer to a webview that i am creating and then remove that view when a user taps the webview. Below is my sample code. What am i doing wrong? Thanks!

- (void) setupPuzzle1
{
puzzleDuration--;
//Create object circle
UIImageView *circleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"red-circle.png"] highlightedImage:[UIImage imageNamed:@"red-circle.png"]];

UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removeImage:)];
recognizer.numberOfTapsRequired = 1;
recognizer.numberOfTouchesRequired = 1;
recognizer.delegate = self;

[circleView addGestureRecognizer:recognizer];

[recognizer release];

int x = rand()%280;
int y = rand()%420;

circleView.frame = CGRectMake(x,y,40,40);
[self.view addSubview:circleView];

if (puzzleDuration > 0)
{
    [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(setupPuzzle1) userInfo:nil repeats:NO];
}

}



#pragma mark - UITapGestureRecognizer methods


- (void)removeImage:(UITapGestureRecognizer *)recognizer
{
NSLog(@"Remove Image");
[[recognizer view] removeFromSuperview];
}

@end

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

    I think you weren’t talking about UIWebView at all. If you did, your code didn’t reflect that. As such you are dealing with UIImageView and the reason is pretty straightforward as any UIImageView object by default has its userInteractionEnabled set to NO. You should change it to YES. So add this line,

    circleView.userInteractionEnabled = YES;
    

    and you aren’t releasing it either. So add

    [circleView release]; 
    

    after you add it as a subview.

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

Sidebar

Related Questions

I'm trying to attach my database on a server that is running SQL2005 and
I'm trying to attach an image on a button in WPF, however this code
I am trying to attach a file with a contact form. My code looks
I'm trying to attach a click function that adds a CSS class to all
I have a user class, where I am trying to attach a profile created
I am trying to attach an image that is picked from the image gallery
I'm using this tickertype jquery plugin: http://www.hungry-media.com/code/jQuery/tickerType/ And I'm trying to attach a hover
I'm trying to attach an event handler to the scroll event that changes the
I'm trying to attach a PDF attachment to an email being sent with System.Net.Mail.
I'm trying to attach an external mdf file to my SQLEXPRESS instance from within

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.