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

The Archive Base Latest Questions

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

I am loading a bunch of images into a UIScrollView, I then resize them

  • 0

I am loading a bunch of images into a UIScrollView, I then resize them and position a button over each, so when I click on the button over the smaller image, it will load up the full size image in a new view.

I am struggling to find a decent way to somehow pass the image’s URL to the click handler as a parameter when the button is clicked, and from what I have read, passing parameters to callback functions is not possible.

Here is the code I have thus far,

for(Card *card in crd){

    pocketImage = [self imageWithImage:[UIImage imageNamed:@"pocket.png"] scaledToSize:CGSizeMake(245/2,80/2)];
    pocketImageView = [[UIImageView alloc] initWithImage:pocketImage];

    cardImage =  [self maskImage:[UIImage imageNamed:@"animal.jpg"]];
    cardImageView = [[UIImageView alloc] initWithImage:cardImage];

    y = (80/2) * inc;

    if (inc % 2){
        x = 125;
    } else {
        x = 10;
        y += (80/2);
    }

    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn addTarget:self action:@selector(testMe) forControlEvents:UIControlEventTouchUpInside];
    [btn setFrame:CGRectMake(x,y-40,pocketImageView.frame.size.width,pocketImageView.frame.size.height*2)];

    [pocketImageView setFrame:CGRectMake(x,y,245/2,80/2)];
    [cardImageView setFrame:CGRectMake(x,y-40,245/2,80/2)];

    //add the pocketImageView to the container
    [imageContainer addSubview:cardImageView];
    [imageContainer addSubview:pocketImageView];
    [imageContainer addSubview:btn];

    inc++;
}

Callback function,

-(void)testMe {
    NSLog(@"works");
}

So basically that just loops through all of the images, and then appends all of them to a UIScrollView, which works fine, the problem comes in when I try to pass custom parameters to the testMe method, which isn’t possible as far as I know, so how would I be able to click on the button and then display the corresponding full size image in a new view?

  • 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-12T23:04:44+00:00Added an answer on June 12, 2026 at 11:04 pm

    You can use an iVar / (private) @property for this.

    Just set the data you want to have available like this:

    myTransferVariable = // something you need in you testMe method
    

    and use it like this

    -(void)testMe {
        NSLog(@"%@", myTransferVariable);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm loading bunch of images in coverflow using i carousel but i'm not getting
I have a page where I am loading bunch of images initially when the
Loading images into Flex (size < 100kb) causes IE7 memory increase by a megabyte
I have a situation where I am loading a bunch of images. During this
I'm making a image website with a bunch of images on the website, and
I'm trying to load a bunch (about 100) of images into memory, so I
I am loading a bunch of images using knockoutjs. I get a json object
I am loading a bunch of images for a GUI which will pick attributes
I'm trying to find an efficient algorithm for dynamically loading background-images for a bunch
I am interested in loading a bunch of data TEXT files which will then

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.