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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:41:39+00:00 2026-06-11T19:41:39+00:00

I created simple UIScrollView that have images. Each time an image pressed i want

  • 0

I created simple UIScrollView that have images. Each time an image pressed i want to change that image, how can I do it?

I creating this UIScrollView and initializing it with NSMutableArray with images.

      UIScrollView *myScroll = [[UIScrollView alloc] initWithFrame: CGRectMake (0,100,200,30)];
        NSMutableArray = *images = [NSMutableArray alloc] initWithObjects: img1,img2,img3,nil];

for (int i=0; i<3; i++)
{
        UIImageView *imageV = [UIImageView alloc];
        [imageV setImage:[images objectAtIndex:i]];
        [myScroll addSubview:imageV];
        [imageV release];
}


    UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget: self action:@selector (changeImg:)];
    [myScroll addGestureRecognizer: singleTap];

and the toucing I’m cathing with the touched place on the scroll:

- (void) singleTapGestureCaptured:(UITapGesturerecongnizer *) gesture
{
    CGPoint touch = [gesture locationInView:myScroll];

}

By X,Y of touched item i know what image was selected

Here I need to change for example the first image of myScroll…How can i do it?

  • 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-11T19:41:40+00:00Added an answer on June 11, 2026 at 7:41 pm

    Add UITapGestureRecognizer on UIImageView and set its userInractionEnabled: YES which is NO by default for UIImageView.

    UIScrollView *myScroll = [[UIScrollView alloc] initWithFrame: CGRectMake (0,100,200,30)];
    NSMutableArray = *images = [NSMutableArray alloc] initWithObjects: img1,img2,img3,nil];
    
    for (int i=0; i<3; i++)
    {
        //In your question you didn't set `imageView` frame so correct it
        UIImageView *imageV = [[UIImageView alloc]initWithFrame:yourFrame];
        [imageV setImage:[images objectAtIndex:i]];
        [imageV setUserInteractionEnabled:YES];
        UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget: self action:@selector (changeImg:)];
        [imageV addGestureRecognizer: singleTap];
        [myScroll addSubview:imageV];
        [imageV release];
    }
    

    After adding all imageView successfully you get them click like this :-

    -(void)changeImg:(id)sender
     {
         UIGestureRecognizer *recognizer = (UIGestureRecognizer*)sender;
         UIImageView *imageView = (UIImageView *)recognizer.view;
         [imageView setImage:[UIImage imageNamed:@"anyImage.png"]];
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want help with my UIScrollView sample. I created a simple program that scrolls
Could someone help me on this, I have created simple web services using axis2
I have created a UIScrollView in my app - adapted from this sample code:
Have created simple Ajax enabled contact forms before that have around 12 fields -
I have created simple application in windows sharepoint services. Now I want to deploy
I want to create a subclass of UITableView or UIScrollView that will have some
I have created simple web service for my website that generates some json based
I have created sample circular UIScrollview.it works fine.but i want to scroll through NSTimer
I have created simple .NET Web Service (ASMX) that I call from my .NET
Ok I created simple user control that look like this <%@ Control Language=C# AutoEventWireup=true

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.