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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:40:28+00:00 2026-06-10T19:40:28+00:00

I’m confused. I have a navigation controller with a BarItem which opens a first

  • 0

I’m confused. I have a navigation controller with a BarItem which opens a first view. After some work is done, I want this view to disappear and I want a second view to open.

  • root view: navigation controller
  • first view: activity indicator, where some data is put together
  • second view: MFMailComposeViewController

In the root view, the BarItem runs these lines to open the first view:

    IndicatorViewController *indicator = [[IndicatorViewController alloc] initWithNibName:@"IndicatorViewController" bundle:nil];

    indicator.view.backgroundColor = [UIColor clearColor];
    self.modalPresentationStyle = UIModalPresentationCurrentContext;
    [self presentModalViewController:indicator animated:YES];

The first view (IndicatorViewController) does some work and finally runs

[self dismissModalViewControllerAnimated:YES];

This works fine. But – how do I open the second view?

I tried this:

I open the second view. After closing the second view, my first view pops up again (since it is still there) and get’s dismissed at this point. This code is placed in the first view:

- (void) viewDidAppear:(BOOL)animated {
    static BOOL firstTime = YES;
    if (firstTime) {
        //do stuff that takes some time (that's why I show the indicator)
        MailViewController *controller = [[MailViewController alloc] init];

        if (controller) 
           [self presentModalViewController:controller animated:YES]; 
        firstTime = NO;
    } else {
        [self dismissModalViewControllerAnimated:YES];
    }    
}

Since the first view pops up again, the user can see the indicator one more time, after the second view is closed – and that is not what I want.

What am I missing here? What would be the better way to do this?

  • 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-10T19:40:29+00:00Added an answer on June 10, 2026 at 7:40 pm

    I would do something like this. Make a navigationController, and make the first view as the root controller. Then do something like this:

    FirstView.m
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        [self.navigationController setNavigationBarHidden:YES];
    }
    
    - (void) nextView { // however you get to your next view, button/action/etc.
        UIViewController *screen = [self.storyboard instantiateViewControllerWithIdentifier:@"yourIdentifier"];
        [self.navigationController pushViewController:screen animated:YES];
    }
    

    Then in the second view:

    SecondView.m
    - (void) nextView { // however you get to your next view, button/action/etc.
        UIViewController *screen = [self.storyboard instantiateViewControllerWithIdentifier:@"yourIdentifier"];
        [self.navigationController pushViewController:screen animated:YES];
    }
    

    And finally in the rootview:

    RootView.m
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        NSArray *navStack = [NSArray arrayWithObject:self];
        self.navigationController.viewControllers = navStack;
        [self.navigationController setNavigationBarHidden:NO];
    }
    

    This will make your RootView the new rootview of the NavigationController.

    self.navigationController.viewControllers

    is the array with all the ViewControllers that are on the navcontrollers stack. The first object is the rootcontroller. If we replace the whole array with our own array, it knows only one item. You CAN go back by dismissing if that’s what you want though. This isn’t the prettiest way of doing it, but it’s not the worst either.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I have an autohotkey script which looks up a word in a bilingual dictionary
I have a text area in my form which accepts all possible characters from
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have a view passing on information from a database: def serve_article(request, id): served_article
I have an array which has BIG numbers and small numbers in it. I
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.