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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:43:50+00:00 2026-05-17T02:43:50+00:00

I have a uiscrollview and i am showing some dynamically generated uiimageview over it.

  • 0

I have a uiscrollview and i am showing some dynamically generated uiimageview over it. Now i want to do an action on touch at any of these images. I tried using touchbegn method but it is not being called. Please advice me what i am doing wrong.

int numofRows = [arrMyPhotos count]/3;
    if([arrMyPhotos count]%3>0)
        numofRows++;
    scrlPhotoList.contentSize = CGSizeMake(320, numofRows*100);
    for(int i = 0;i<numofRows;i++) {
        x = 10;
        j = 0;
        while (j<3 && k<[arrMyPhotos count]) {
            NSString *pngFilePath = [[NSString stringWithFormat:@"%@/",docDir] stringByAppendingFormat:@"%@",[(NSDictionary*)[arrMyPhotos objectAtIndex:k] objectForKey:@"picName"]];
            NSLog(@"%@",pngFilePath);
            UIImage *img = [UIImage imageWithContentsOfFile:pngFilePath];
            if(img!=nil) {
                UIImageView *imgVw = [[UIImageView alloc] init];
                imgVw.image = [self imageByScalingAndCroppingForSize:CGRectMake(0, 0, 95, 95) image:img];
                imgVw.tag = k;
                imgVw.frame = CGRectMake(x, y, 95, 95);
                imgVw.userInteractionEnabled = TRUE;
                imgVw.multipleTouchEnabled = TRUE;

                [scrlPhotoList addSubview:imgVw];
                //k++;
                x = x+105;
                j++;
            }
            k++;
        }
        y = y+105;
    }
    [self.view addSubview:scrlPhotoList];



-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
    UITouch *touch = [[event allTouches] anyObject];
    //CGPoint touchLocation = [touch locationInView:self.view];

    if(([touch view]).tag>0) {
        NSLog(@"%d",([touch view]).tag);
    }
}
  • 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-17T02:43:50+00:00Added an answer on May 17, 2026 at 2:43 am

    Your code seems to be in the UIControllerView, for handling touch events you need to extend the view you want to implement the touch on and the controller!.

    If what you want, is a basic touch events you’ll need to have UIButton or some other UIView that supports touch events

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

Sidebar

Related Questions

I have a UIScrollview with a UIImageview inside it showing a floor plan. I
I have a UIScrollView containing a UIImageView. now I also added a two finger
I have a UIScrollView which contains multiple UIImageViews. I want to know which UIImageView
I have an UIScrollView with lots of tagged images. I have to process some
I have UIScrollView and number of objects (UIView compositions) with UIImageViews inside them. Some
I have a UIScrollView and I want it to be able to scroll in
I have a CATiledLayer inside a UIScrollView and all is working fine. Now I
I have a UIScrollView loaded with a UIImageView, so that the user can zoom
I have a UIScrollView added to a UIView. Now i have added a background
I have a UIScrollView whose content size is 1200x480. I have some image views

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.