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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:47:19+00:00 2026-05-28T17:47:19+00:00

I’ve managed to make these views push each other off the screen with a

  • 0

I’ve managed to make these views push each other off the screen with a button click.

However when the device is changed to landscape orientation, the view only pushes half way off the screen and sticks. I understand why this happens but not how to fix it.

Is there a way to make the view slide entirely off the screen on a button click in both portrait and orientation mode? That’s all I need it to do.

My code reads like this

.h file

@interface AnimationBlocksViewController : UIViewController{
    IBOutlet UIView *theview;
    IBOutlet UIView *theview2;

    BOOL isAnimated;
    BOOL switchback;
}

-(IBAction)animate:(id)sender;
-(IBAction)change:(id)sender;

@end

.m file

- (void)viewDidLoad
{

    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    isAnimated = NO;
}

-(IBAction)animate:(id)sender;{
    if (isAnimated) {

        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
        [UIView setAnimationDuration:0.5];
        [theview setFrame:CGRectMake(0, 0, 320, 460)];
        [theview2 setFrame:CGRectMake(320, 0, 320, 460)];
        [UIView commitAnimations];
        isAnimated=YES;

    }


    else{

        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
        [UIView setAnimationDuration:0.5];
        [theview setFrame:CGRectMake(-320, 0, 320, 460)];
        [theview2 setFrame:CGRectMake(0, 0, 320, 460)];
        [UIView commitAnimations];
        isAnimated=NO;

    }
}

-(IBAction)change:(id)sender;{
    if (switchback) {

        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
        [UIView setAnimationDuration:0.5];
        [theview2 setFrame:CGRectMake(0, 0, 320, 460)];
        [UIView commitAnimations];
        switchback=NO;

    }


    else{

        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
        [UIView setAnimationDuration:0.5];
        [theview2 setFrame:CGRectMake(320, 0, 320, 460)];
        [theview setFrame:CGRectMake(0, 0, 320, 460)];
        [UIView commitAnimations];
        switchback=NO;

    }
}

I appreciate any feedback, samples, or links to similar questions or tutorials.

Thank you

  • 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-28T17:47:20+00:00Added an answer on May 28, 2026 at 5:47 pm

    Rather than rely on these constant values you might simplify this behavior by setting the coordinates of theview and theview2 based on the current bounds of your view controller’s view ie [theview2 setFrame:CGRectMake(self.view.bounds.size.width, 0, 320, 460)];. That way you don’t need to rely on keeping track of fixed sizes (which will change if for example your app is run while a user is on a call, if you later choose to hide the status bar, or if you put this view controller inside a navigation or tab bar controller).

    Going further we could base the sizes of these views entirely on the bounds of the view controller’s view:

    CGRect frameForView2 = self.view.bounds;
    frameForView2.origin.x = frameForView2.size.width;
    [theview2 setFrame:frameForView2];
    

    That way you not only make sure to move the view completely outside it’s parent view but can also make sure that your subviews fill their parent when you move them back (because you are setting their width and height equal to that parent view’s width and height).

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is

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.