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

  • Home
  • SEARCH
  • 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 8486619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:59:45+00:00 2026-06-10T20:59:45+00:00

I am making simple storyboard application which has 2 UIViewControllers and I am switching

  • 0

I am making simple storyboard application which has 2 UIViewControllers and I am switching between them by using modal segue. Each UIViewController has one UIButton which is used to perform segue to another UIViewController. In viewDidLoad method I animate appearance of that UIButton on each UIViewController. I am using Cross Dissolve Modal segue.

When I press UIButton on 1st UIViewController I navigate to second UIViewController and animation is executed and 2nd UIViewController is shown. After I press UIButton on 2nd UIView Controller, first UIViewController is shown and it’s animation is executed. Everything looks fine and viewDidLoad methods are called for each UIViewController when ever I navigate to it. And that’s great.

I tried now to change Modal segue type from Cross Dissolve to other two by default offered in XCode Interface Builder. I changed to Cover Vertical, and everything worked just fine, without changes. But when I tried Flip Horizontal Modal segue, I saw a problem.

When performing Flip Horizontal Modal segue, my UIButton on both UIViewControllers is shown, but animation isn’t executed. I tried debugging and I am sure that animation commands are being executed, but animation isn’t shown.

So that’s my first question: Does anyone know is there any difference between these types of Modal segues which may cause my animation not showing up?

Other questions are related to basic theory of segues and memory management. When I perform segue and navigate to some UIViewController, viewDidLoad method is called every time. So, does that mean I created new object instance each time viewDidLoad method was executed?

I also notice that viewDidUnload method is never called. So, if answer to previous question is affirmative (each viewDidLoad execution creates new object instance), does that mean that my UIViewController object instances are never being unloaded and deleted? Or ARC is doing garbage collection behind the scenes?

If someone could explain how things works with storyboard segues and memory management/object lifecycle and why viewDidUnload method is never being called, I’d be very grateful.


[edit #1: Trying to unload UIViewController after performing modal segue]

[update #1: This shouldn’t be done, viewDidUnload will be called automatically]

I am making segue in IBAction attached to UIButton click. I have written this peace of code to perform modal segue.

@try
{
    [self performSegueWithIdentifier:segueToPerform sender:self];
}
@catch (NSException *exception) 
{
    NSLog(@"Exception: %@", exception);
}
@finally
{
    [self viewDidUnload];
}

I have manually called viewDidUnload in @finally block and I have checked weather viewDidUnload is called in runtime and yes – it is called.

Does this mean I managed to unload my UIViewController object I created when navigating to it with modal segue from another UIViewController and remove it from memory?

Is this method regular as a replacement for:

[self dismissViewControllerAnimated:YES completion:nil];

because this above line returns me to UIViewController from which I navigated to current UIViewController, but that doesn’t fit my needs, because I need to perform new segues from current UIViewController to other UIViewControllers (beside returning back to UIViewController from which I navigated to current one)?


[edit #2: Finish]

At the end I changed implementation model and loaded new UIViews under single UIViewController after I created separate XIB files for those UIViews. I have marked answer from @dasblinkenlight as the right one since it contains lots of useful informations and discussion on that answer gives good answers to some doubts about using modal segues.

  • 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-10T20:59:47+00:00Added an answer on June 10, 2026 at 8:59 pm

    I do not know the answer to the first part of your question, but once you learn the answer to the second part, I am sure that you would go with a different solution anyway.

    viewDidLoad method is called every time. So, does that mean I created new object instance each time viewDidLoad method was executed?

    Absolutely. “Modal” segue causes the new view to obscure the old one completely until the new view is closed. If you go back and forth many times, your code will accumulate a whole “stack” of views underneath the current one.

    I also notice that viewDidUnload method is never called. So, if answer to previous question is affirmative (each viewDidLoad execution creates new object instance), does that mean that my UIViewController object instances are never being unloaded and deleted?

    This is correct, all the view controllers that you create are still there, ready for you to close the views on top of it.

    Or ARC is doing garbage collection behind the scenes?

    ARC is not a garbage collector, it is a reference counting mechanism with a little automation from the compiler. The objects are still there.

    You should change your code to call

    [self dismissModalViewControllerAnimated:YES];
    

    in the second controller, rather than using a modal segue that brings you back to the first one.

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

Sidebar

Related Questions

I am making simple connection between two table - first one called users has
I'm currently making a simple inventory system application using Excel VBA. I have a
Making a simple application, so when the user logs out of Windows, it of
I'm making a simple app using the HTML5 <canvas> tag and compile the code
I am making simple one on server side & one on client side application
I'm making simple C# Winform application. There is a Form having a textbox. I
How to create simple post/get API making simple calling to GAE database using Google
How to change sizes of ViewController? I'm making simple app which uses deliberately two
I'm making a simple vim function that counts to n in binary (each number
Making a simple three question PHP quiz. Each question is displayed on a page

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.