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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:11:26+00:00 2026-06-10T21:11:26+00:00

So I have a viewController A that presents a modal viewController B. Then B

  • 0

So I have a viewController A that presents a modal viewController B.

Then B presents a viewController C.

What I’m trying to do is to dismiss viewController B since I dont need it anymore. Is there a simple way to dismiss B and keep C on the screen as a child of A maybe?

  • 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-10T21:11:27+00:00Added an answer on June 10, 2026 at 9:11 pm

    Obviously, as many have said, this in a textbook world would/should be a delegate situation. Where A presents B and B presents C. Then when C is done it tells B which dismisses C and then B tells A to dismiss B.

    I would argue that you are essentially creating a set of modally presented view controllers that amounts to a navigation stack. I would likely implement it as such. Where A would be the root view controller. A would then push B onto the stack and B would push C onto the stack. When C was done it could simply popToRootViewControllerAnimated: or popToViewController:A animated:YES if A was not the rootViewController.

    Also removing B out from underneath of C seems problematic. But it doesn’t sound like that is set in stone based on your comment:

    But anyway its not a the end of the world if I keep that
    viewController there for a while. –

    That would at least enable a fairly clean delegate setup.

    Still it seems like you basically know that when the user is done with C they would never need B again. If this is the case you can blindly dismiss two or more view controllers at once. And the code for two at a time is fairly simple. (assuming iOS version > 5.0)

    [self.presentingViewController.presentingViewController dismissModalViewControllerAnimated:YES];
    

    Please note that I said blindly! This code is not forgiving and makes assumptions. For example most obviously that the view controller does in fact have a presentingViewController and that that view controller has a presentingViewController. If either of these criteria is not met then this code will do nothing. This could easily happen if you at any point restructure your app.

    So again, if you choose to use this line of code, use it very carefully. And please do consider using a UINavigationController for this view hierarchy, or at least delegation.

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

Sidebar

Related Questions

I have a UITabBarController that adds a viewController, but the positioning is off. There
I have a main screen that presents a modal view controller. When the modal
I have a viewController that presents a modalViewController when a UINavigationBarItem is touched. After
I have something like a modal view controller that I need to display above
I have a modal view controller that I am trying to present a web
In my app I have a function that presents a modal view controller when
Ever since iOS5, I have a problem where when I present and then dismiss
I have a ViewController that includes its own .nib file, I am wanting to
I have a ViewController that has its own NIB. I would like to embed
I have a viewController that autorotates just fine, The problem is that is I

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.