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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:09:08+00:00 2026-06-01T20:09:08+00:00

I have the following environment: root view controller is UINavigationController a number of custom

  • 0

I have the following environment:

  • root view controller is UINavigationController
  • a number of custom UIViewControllers may be pushed on the navigation stack
  • each of custom controllers may or may not present a modal view controller
  • I need to be able to programmatically manage the navigation stack (for example – drop all controllers from the navigation stack except the root controller as response to some external event like push notification delivery)

Naive implementation with [navigationController setViewControllers:newControllers animated:animated]; obviously fails if there was a modal view controller presented by any of old controllers ind the stack:

  1. This modal controller stays visible
  2. If a delegation pattern is used for parent<->modal controllers communication (parent is delegate of presented modal view controller) any action in modal view controller results in crash since delegate was already released

So the general problem is that modal controler lifcycle is not bound to the parent controller. My questions are:

  1. Is there a stadard approach for managing this kind of hierarchy and safe navigation stack changes?
  2. If NO than what would be a best custom implementation? I’m seeing two general approaches – one is to explicitly dismiss/unlink all modal contrellers in the code changing the navigation stack, the other is to add logic to parent view contollers to manage modal controllers lifecycle directly.
  • 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-01T20:09:09+00:00Added an answer on June 1, 2026 at 8:09 pm

    There is no standard approach because this behaviour is discouraged by the HIG. Even in the event of push notifications, you’re not supposed to modify the existing stack except through pushes, pops, and pop-to-root. However, what you’re asking is completely possible.

    You have several options, but the best is probably notifications. Use NSNotificationCenter in your app delegate to let any interested view controller’s know that you’re about to pop to your root view controller. In each of your modal view controllers, register for this notification name and dismiss yourself when notified. After dismissing your modals, you can just use popToRootViewController and avoid messiness with modifying the stack.

    Take a look at TweetBot and see how they handle push notifications. They do a pretty good job, I believe, and they just present a new modal view controller. You can do this (nested modal presentations), so experiment around and see what you can do without jarring the user.

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

Sidebar

Related Questions

we have the following environment: a Windows 2008 Server with Apache 2.2.14 and SVN
I have following this blog in setting Xvfb in my ubuntu environment: http://corpocrat.com/2008/08/19/how-to-install-xvfb-x11-server-in-linux-server/ So
How do you setup a multi-developer XDebug PHP environment? I have the following setup:
We have Windows Server 2008 as our Production server hosted in RackSpace environment. Following
In my bootstrap.php I have the following: if($_SERVER['SERVER_NAME'] == 'localhost') Kohana::$environment = 'development'; else
We have the following project setup: Root (pom) | +-- s1: Service 1 (war)
I have the following config in my lighttpd.conf: $HTTP[host] == trac.domain.tld { server.document-root =
I have the following (simplified) XML that I get in a system environment: <?xml
I have an XML file of the following structure: <?xml version=1.0 encoding=utf-8?> <root> <ArrayOfLocationDTO
I have following situation: I have loged user, standard authentication with DB table $authAdapter

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.