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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:04:40+00:00 2026-06-12T20:04:40+00:00

i am using custom UIImageview for detect touch? but i am unable to detect

  • 0

i am using custom UIImageview for detect touch? but i am unable to detect touch on that particular imageview.

-(void)viewDidLoad {
  [super viewDidLoad];
  mainView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 200)];
  image = [[UIImageView alloc] initWithFrame:CGRectMake(10, 300, 100, 100)];
  image.image = [UIImage imageNamed:@"CyanSquare.png"];
  image2 = [[UIImageView alloc] initWithFrame:CGRectMake(150, 600, 100, 100)];
  image2.image = [UIImage imageNamed:@"CyanSquare.png"];
  image.tag = 1;
  image2.tag = 2;
  [self.mainView addSubview:image];
  [self.mainView addSubview:image2];
  [self.view addSubview:mainView];
}

-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {

   UITouch *touch = [[event allTouches] anyObject];
   [super touchesBegan:touches withEvent:event];
   if ([touch view] == [image viewWithTag:1]) {
    NSLog(@"touch  beggin 1");
    mainView.image = [UIImage imageNamed:@"VideoBkGround.png"];
   }
   if ([touch view] == [image2 viewWithTag:2])
    {
    NSLog(@"touch  beggin 2");
    mainView.image = [UIImage imageNamed:@"VideoRunning.png"];
   }
 }

In this code i am not detect touch? pls help me?

with out custom view’s it’s detected.

  • 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-12T20:04:41+00:00Added an answer on June 12, 2026 at 8:04 pm

    You need to enable user interaction for UIImageViews you want to interact with.

    @property(nonatomic, getter=isUserInteractionEnabled) BOOL userInteractionEnabled

    something like that:

    image.userInteractionEnabled = YES; 
    image2.userInteractionEnabled = YES;
    

    otherwise the images will not get touches…

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

Sidebar

Related Questions

I am using a custom subclass of UIImageView, but I can't figure out why
I'm aware of using custom configuration values for my custom services, but what if
I'm using custom class that subclass from UILabel. It works fine unless I change
I'm using custom renderer on JList, but none of components rendered are accessible. list.setCellRenderer(new
I am using custom model binder in ASP.NET MVC 2 that looks like this:
I have a custom UIImageView class that creates thumbnails (UIImageView) and each thumbnail has
I am creating custom cell contain UILabel , UIImageView ,using constant tag for UILabel
I've managed to add a custom background to my navigation bar by using: UIImageView
I have a custom UITableViewCell that consists of a UIImageView and a UILabel. The
i am using a custom uitablecellview like i used to do .But ,unfortunately ,this

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.