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

The Archive Base Latest Questions

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

iPad app. OS 4.2. I have a button that, when pressed, calls this function

  • 0

iPad app. OS 4.2.

I have a button that, when pressed, calls this function that creates a UIImageView and animates it (and calls a second animation block). I created another button that calls the same function and passes different locations and different URL to a graphic.

I’m starting to get glitches—the first graphic spawned from the first button has the locations passed from the second button. This is probably due to the fact that I am not dynamically naming the UIImageView and getting collisions from that.

So how do I dynamically create and name any infinite number of UIImageViews? Especially since, to reference the UIImageView in two functions, it needs to be declared outside of the functions.

    -(void)makeSoundEffectWordAppear:(NSString *)imageName:(int)startingX:(int)startingY:(int)endingX:(int)endingY{
        myImage = [UIImage imageNamed:imageName];
        [testWord setImage:myImage];
        testWord = [[[UIImageView alloc] initWithFrame:CGRectMake(startingX,startingY,myImage.size.width,myImage.size.height)] autorelease];    
        [self.view addSubview:testWord];
        testWord.alpha=0;
        testWord.transform = CGAffineTransformMakeScale(.5, .5);

        [UIView beginAnimations:@"moveWord" context:nil];
            [UIView setAnimationDelegate:self];
            [UIView setAnimationDidStopSelector:@selector(fadeWord:finished:context:)];
            //[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
            [UIView setAnimationDuration:1];

            [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
            [UIView setAnimationBeginsFromCurrentState:YES];
            testWord.transform = CGAffineTransformMakeScale(1, 1);
            testWord.center = CGPointMake(endingX,endingY);
                        testWord.alpha=1;
        [UIView commitAnimations];
    }

- (void)fadeWord:(NSString *)animationID finished:(BOOL)finished context:(void *)context{
        [UIView beginAnimations:@"makeWordFade" context:nil];
    [UIView setAnimationDelegate:self];
        [UIView setAnimationDelay:5];
        testWord.alpha=0;
        testWord.transform = CGAffineTransformMakeScale(.5, .5);
        [UIView setAnimationDuration:1];
    [UIView commitAnimations];
}
  • 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-18T06:50:23+00:00Added an answer on May 18, 2026 at 6:50 am

    You have a single pointer to testWord rather than a pointer for each instance. You should be using the context property of animations to pass in the specific UIImageView you want to fade away:

    -(void)makeSoundEffectWordAppear:(NSString *)imageName:(int)startingX:(int)startingY:(int)endingX:(int)endingY{
        UIImage *myImage = [UIImage imageNamed:imageName];
        UIImageView *testWord = [[[UIImageView alloc] initWithImage:myImage] autorelease];
        CGRect frame = [testWord frame];
        frame.origin.x = startingX;
        frame.origin.y = startingY;
        [testWord setFrame:frame];
        [self.view addSubview:testWord];
        testWord.alpha=0;
        testWord.transform = CGAffineTransformMakeScale(.5, .5);
    
        [UIView beginAnimations:@"moveWord" context:testWord];
            [UIView setAnimationDelegate:self];
            [UIView setAnimationDidStopSelector:@selector(fadeWord:finished:context:)];
            //[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
            [UIView setAnimationDuration:1];
    
            [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
            [UIView setAnimationBeginsFromCurrentState:YES];
            testWord.transform = CGAffineTransformMakeScale(1, 1);
            testWord.center = CGPointMake(endingX,endingY);
                        testWord.alpha=1;
        [UIView commitAnimations];
    }
    
    - (void)fadeWord:(NSString *)animationID finished:(BOOL)finished context:(void *)context{
        UIImageView *testWord = (UIImageView *)context;
        [UIView beginAnimations:@"makeWordFade" context:context];
            [UIView setAnimationDelegate:self];
            [UIView setAnimationDelay:5];
            testWord.alpha=0;
            testWord.transform = CGAffineTransformMakeScale(.5, .5);
            [UIView setAnimationDuration:1];
        [UIView commitAnimations];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to be able to create a GUID/UUID on the iPhone and iPad.
How do I pad a numeric string with zeroes to the left, so that
How can I pad a string with spaces on the left when using printf?

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.