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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:09:46+00:00 2026-05-23T10:09:46+00:00

I have several views that I open one after another modally. View1 calls View2

  • 0

I have several views that I open one after another modally. View1 calls View2 and View2 calls View3.
I use this code to call the next view:

   View2 *myView = [[View2 alloc] initWithNibName:@"View2" bundle:[NSBundle mainBundle]];   

    [self presentModalViewController:myView animated:YES];

    [myView release];

If the user pushes cancel then it goes back one View… 3 to 2 and 2 to 1

[self.parentViewController dismissModalViewControllerAnimated:YES];

What I need to do is when the user is on View3 if they don’t select cancel but complete the operation, then I need to go back to View1 and release View2 and View3.

How do I do that?

EDIT: The MAIN WINDOW has a Navcontroller and 6 view controllers. I call the View 1 like this:

View1 *screen = [[View1 alloc] initWithNibName:@"View1" bundle:[NSBundle mainBundle]];
    self.Search = screen;

    [mainNavController presentModalViewController:screen animated:YES];

    [screen release];

EDIT #2:
Main Windows calls View 1. Main Window has a NavController in the XIB this works:

    View1 *screen = [[View1 alloc] initWithNibName:@"View1" bundle:[NSBundle mainBundle]];


[mainNavController presentModalViewController:screen animated:YES];

[screen release];

Then in the XIB on View 1 I added a NavController and tied it to View1NavController in the .h

View 1 then calls view 2:

   View2 *myView = [[[View2 alloc] initWithNibName:@"View2" bundle:nil] autorelease];

UINavigationController * navController = [[[UINavigationController alloc] initWithRootViewController:myView] autorelease]; 

[View1NavController presentModalViewController:navController animated:YES];

When I execute this, no errors, but it doesnt show the View2.

  • 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-23T10:09:47+00:00Added an answer on May 23, 2026 at 10:09 am

    Why don’t you use UINavigationController? You can use both popToRootViewControllerAnimated: and popViewControllerAnimated: for your purpose.

    As such if you do,

    [self.parentViewController.parentViewController dismissModalViewControllerAnimated:YES];
    

    You should go back to 1.

    Excerpt from dismissModalViewControllerAnimated,

    If you present several modal view controllers in succession, and thus build a stack of modal view controllers, calling this method on a view controller lower in the stack dismisses its immediate child view controller and all view controllers above that child on the stack. When this happens, only the top-most view is dismissed in an animated fashion; any intermediate view controllers are simply removed from the stack. The top-most view is dismissed using its modal transition style, which may differ from the styles used by other view controllers lower in the stack.

    Using Navigation Controller

    For navigation controller to work, instead of where your load your view1 you will do this,

    View1 *myView = [[[View1 alloc] initWithNibName:@"View1" bundle:nil] autorelease]; 
    UINavigationController * navController = [[[UINavigationController alloc] initWithRootViewController:myView] autorelease]
    
    [mainNavController presentModalViewController:navController animated:YES];
    

    This is assuming that view1 was the rootViewController

    Once you’ve the navigation controller set up then you can load view2 like this,

    View2 *myView = [[View2 alloc] initWithNibName:@"View2" bundle:[NSBundle mainBundle]];   
    [self.navigationController pushViewController:myView animated:YES];
    [myView release];
    

    In such case,

    Cancel

    [self.navigationController popViewControllerAnimated:YES];
    

    Complete

    [self.navigationController popToRootViewControllerAnimated:YES];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two nib files, one that will open at startup and another that
I have an Open GL application that renders a simulation animation and outputs several
The layout... I have a UIToolbar that loads a view with several buttons. One
I have a page with several links that open a separate window with varying
I have an iPhone application that contains several views and their associated controllers. Looking
I have a several views that I can drag around, rotate, scale. I want
Assume I have several Views in my WPF application that all show a report,
I have several views of class MyView (subclass of NSView ) inside another NSView
On one of the edit views of my Grails application I have several chained
I have a view controller class that has to implement several protocols. Too keep

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.