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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:14:58+00:00 2026-05-29T05:14:58+00:00

In my app when I am switching views with an animation using UIView animations,

  • 0

In my app when I am switching views with an animation using UIView animations, it works fine the first time when I switch views because the view slides properly into place and everything works. But if I switch back to my original view and then go BACK to the new view, it does not show anything, the view is black but I know my method is getting called.

My code is below, but does anyone see anything that is wrong?

-(void)changeView2ToView3 {
    [view2.view.superview addSubview:view3.view];
    [view3.view setFrame:CGRectMake(0, kHeight, kWidth, kHeight)];
    [UIView animateWithDuration:0.75 
                     animations:^{
                         [view3.view setFrame:CGRectMake(0, 0, kWidth, kHeight)];  
                     }
                     completion:^(BOOL finished){
                         [view2.view removeFromSuperview];
                     }];
}

kHeight and kWidth are the height and width of the screen and they are never 0 or nil.

Thanks!

  • 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-29T05:14:58+00:00Added an answer on May 29, 2026 at 5:14 am

    After the first time, view2.view’s superview must be nil. So you have to set a variable for saving the superview.

    [view2.view removeFromSuperview];
    // now view2.view.superview == nil;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my app when I am switching views with an animation using UIView animations,
In order to switch between views in my iOS app, I have been using
In my app when I am switching views, after about the 4th time I
Currently I am having a issue switching views using Core Animation. I want to
When Switching between two view controllers, what's the difference between addSubView or using a
I'm having trouble switching views with button presses in my Android app. The code
In my app I want to add a custom transition when switching views. Since
I'm switching views in the context of a navigation view heirarchy, and I want
I'm working on an app in which I want the viewstack to switch views
I'm trying to write a faster user switching app for Windows. Win+L and selecting

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.