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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:02:12+00:00 2026-05-28T01:02:12+00:00

In iOS 4, if you want to dismiss two nested modal view controllers, the

  • 0

In iOS 4, if you want to dismiss two nested modal view controllers, the following code works:

[[[[self parentViewController] parentViewController] parentViewController] dismissModalViewControllerAnimated:YES];

However in iOS 5 this method no longer works. Does anybody know how to achieve this result in iOS 5?

  • 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-28T01:02:13+00:00Added an answer on May 28, 2026 at 1:02 am

    I have an app that closes nested modal view controllers through NSNotificationCenter. The notification is received by the VC that I want to navigate back to and all the VC’s in between are gone.

    In the deeper VC…

    NSNotification * notification = [NSNotification notificationWithName:@"BACKTOINDEXNOTE" object:nil];
    [[NSNotificationCenter defaultCenter] postNotification:notification];
    

    In the VC I would like to go back to

    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    {
       self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
       if (self) {
           [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dismiss) name:@"BACKTOINDEXNOTE" object:nil];
    
           // more init code
       }
       return self;
    }
    
    -(void)dismiss
    {
      [self dismissModalViewControllerAnimated:YES];
    }
    

    This works on iOS 5 device with a project deployed for 4.0+
    I hope it helps. If you use this, it will scale to support more VC’s in between your current VC and the one you want to dismiss to, without changing this code

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

Sidebar

Related Questions

I want to create a custom alert view within my iOS application. For example,
I'm working on an iOS app where I want to load one view if
I want to make http form post using NSURLConnection in iOS. I have two
I have create an IOS app. The app has MainViewController that will present/dismiss Modal
I want to provide two versions of my iOS app: paid and free with
I want to add code to my iOS app which prompts users to follow
I want to add code to my iOS app which prompts users to like
I need help with my code on Cocoa Touch (for iOS/iPhone). I want a
On iOS if I want to overlay two views and then blend from one
I'm writing an iOS app with a table view inside a tab view. In

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.