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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:25:31+00:00 2026-05-20T06:25:31+00:00

I am displaying two images in my iPhone app, one on top, one on

  • 0

I am displaying two images in my iPhone app, one on top, one on the bottom. They cover the entire screen. The user, with a swipe gesture, can change either of the images, depending on where the swipe started.

I want the image to change with an animated transition. It currently works without animation, or with the entire screen transitioning. Is it possible to make the transition occur over part of the screen?

I load the images for the first time (in viewDidLoad) thus:

// top image
UIImage *topImage = [UIImage imageNamed:@"top1.png"];
CGRect topframe = CGRectMake(0.0f, 0.0f, 320.0f, 240.0f);
UIImageView *topView = [[UIImageView alloc] initWithFrame:topframe];
topView.image = topImage;
[self.view addSubview:topView];
[topView release];

// bottom image
UIImage *bottomImage = [UIImage imageNamed:@"bottom1.png"];
CGRect bottomframe = CGRectMake(0.0f, 240.0f, 320.0f, 240.0f);
UIImageView *bottomView = [[UIImageView alloc] initWithFrame:bottomframe];
bottomView.image = bottomImage;
[self.view addSubview:bottomView];
[bottomView release];

When I detect a swipe, and detect which of the two images are to be changed, I call a routine like this one:

- (void)changeTopImage:(NSString *)newImage {
    UIImage *topImage = [UIImage imageNamed:newImage];
    CGRect topframe = CGRectMake(0.0f, 0.0f, 320.0f, 240.0f);
    UIImageView *topView = [[UIImageView alloc] initWithFrame:topframe];
    topView.image = topImage;
    [self.view addSubview:topView];
    [topView release];
}

Essentilly, I’m continually loading images on top of each other. Is that the best way to do it, especially in terms of memory management?

Everything else I’ve tried, using techniques such as below, make the entire screen transition:

[UIView beginAnimations:nil context:nil];
...
[UIView commitAnimations];

Thanks for any leads on which way I should be going on this.

  • 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-20T06:25:31+00:00Added an answer on May 20, 2026 at 6:25 am

    well, an easy way could be this (repeat for the bottomImage):

    don’t release topView when you load it the first time in your method,
    but declare it in your .h file,
    and use a tempView too:

    @interface YourClass: UIViewController{
        UIImageView *topView;
        UIImageView *tempView;
    }
    

    this way you can call them to move them and remove them when you load a new image

    then in .m:

    EDIT: some correction (see coco’s comments):

    [a] [b] line 4 = [c] line 11:

    - (void)changeTopImage:(NSString *)newImage {
        UIImage *topImage = [UIImage imageNamed:newImage];
        //CGRect topframe = CGRectMake(0.0f, 0.0f, (320.0f + 320), 240.0f);
        CGRect topframe = CGRectMake((0.0f + 320), 0.0f, 320.0f, 240.0f);
        tempView = [[UIImageView alloc] initWithFrame:topframe];
        //topView.image = topImage;
        tempView.image = topImage;
        [self.view addSubview:tempView];
        [[UIApplication sharedApplication] beginIgnoringInteractionEvents];
    
        [UIView beginAnimations:@"animation" context:NULL];
            [UIView setAnimationDuration:0.5];
            [UIView setAnimationDelegate:self];
                    tempView.center = topView.center;
                    // do this to push old topView away, comment next line if wanna new image just cover it
                    //topView.center =  CGPointMake(topView.x - 320, topView.y);
                    topView.center = CGPointMake(topView.center.x - 320, topView.center.y);
                    // call a method when animation has finished:
            [UIView setAnimationDidStopSelector:@selector(endOfAnimation:finished:context:)];
        [UIView commitAnimations];
    }
    
        - (void)endOfAnimation:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context{
    
            [topView removeFromSuperview];
            topView = tempView;
            [tempView release];
            tempView = nil;
            [[UIApplication sharedApplication] endIgnoringInteractionEvents];
        }
    
    - (void)dealloc {
        if (tempView != nil) {
            [tempView release];
        }
        [topView release];
    
        [super dealloc];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two images - 1)a rectangular one, displaying the actual content and 2)a
I have two plots displaying supply and demand, and one plot in which I
I need to place two images into top-left and top-right corners of a web
I have three large UIImageViews displaying images within my iPad app (each is almost
I have an iPhone app that is apparently not displaying its icon on the
I have an Iphone application in which i am combining two arrays and displaying
I have two view's UISlider and UIScrollView added to UIView I am displaying images
I have the following requirements. I am displaying two blank images(ImageView) in landscape mode.
The above image is just adding two values and displaying the result on the
I am displaying two DIV panels with the code below. The only difference between

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.