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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:18:12+00:00 2026-06-08T12:18:12+00:00

I’ve seen this question in various forms without a clear answer. I’m going to

  • 0

I’ve seen this question in various forms without a clear answer. I’m going to ask and answer here. My app needs to do work on startup… inits, a few network calls, login, etc. I don’t want my main view controller working until that’s done. What’s a good pattern for doing this?

Requirements:

  • iOS5+, storyboards, ARC.
  • the main vc’s view cannot appear until the startup work is done.
  • want a choice of transition styles to the main vc when the startup work is done.
  • want to do as much layout as possible in storyboard.
  • the code should be cleanly contained somewhere obvious.
  • 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-08T12:18:13+00:00Added an answer on June 8, 2026 at 12:18 pm

    EDIT, July 2017
    Since the first writing, I’ve changed my practice to one where I give the start up tasks to their own view controller. In that VC, I check startup conditions, present a “busy” UI if needed, etc. Based on the state at startup, I set the window’s root VC.

    In addition to solving the OP problem, this approach has the additional benefits of giving better control of the startup UI and UI transitions. Here’s how to do it:

    In your main storyboard, add a new VC, called LaunchViewController and make it the app’s initial vc. Give your app’s “real” initial vc an identifier like “AppUI” (identifiers are on the Identity tab in IB).

    Identify other vcs that are the starts of main UI flows (e.g. Signup/Login, Tutorial, and so on) and give these descriptive identifiers, too. (Some prefer to keep each flow in it’s own storyboard. That’s a good practice, IMO).

    One other nice optional idea: give your app’s launch storyboard’s vc an identifier, too (like “LaunchVC”), so that you can grab it and use it’s view during startup. This will provide a seamless experience for the user during launch and while you do your startup tasks.

    Here’s what my LaunchViewController looks like….

    @implementation LaunchViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        // optional, but I really like this:
        // cover my view with my launch screen's view for a seamless start
        UIStoryboard *storyboard = [self.class storyboardWithKey:@"UILaunchStoryboardName"];
        UINavigationController *vc = [storyboard instantiateViewControllerWithIdentifier:@"LaunchVC"];
        [self.view addSubview:vc.view];
    }
    
    - (void)viewWillDisappear:(BOOL)animated {
        [super viewWillDisappear:animated];
        [self hideBusyUI];
    }
    
    - (void)viewDidAppear:(BOOL)animated {
        [super viewDidAppear:animated];
        [self showBusyUI];
    
        // start your startup logic here:
        // let's say you need to do a network transaction... 
        //
        [someNetworkCallingObject doSomeNetworkCallCompletion:^(id result, NSError *error) {
            if (/* some condition */) [self.class presentUI:@"AppUI"];
            else if (/* some condition */) [self.class presentUI:@"LoginUI"];
            // etc.
        }];
    }
    
    #pragma mark - Busy UI
    
    // optional, but maybe you want a spinner or something while getting started
    - (void)showBusyUI {
        // in one app, I add a spinner on my launch storyboard vc
        // give it a tag, and give the logo image a tag, too
        // here in animation, I fade out the logo and fade in a spinner
        UIImageView *logo = (UIImageView *)[self.view viewWithTag:32];
        UIActivityIndicatorView *aiv = (UIActivityIndicatorView *)[self.view viewWithTag:33];
        [UIView animateWithDuration:0.5 animations:^{
            logo.alpha = 0.0;
            aiv.alpha = 1.0;
        }];
    }
    
    - (void)hideBusyUI {
        // an animation that reverses the showBusyUI
    }
    
    #pragma mark - Present UI
    
    + (void)presentUI:(NSString *)identifier {
        UIStoryboard *storyboard = [self storyboardWithKey:@"UIMainStoryboardFile"];
        UINavigationController *vc = [storyboard instantiateViewControllerWithIdentifier:identifier];
    
        UIWindow *window = [UIApplication sharedApplication].delegate.window;
        window.rootViewController = vc;
    
        // another bonus of this approach: any VC transition you like to
        // any of the app's main flows
        [UIView transitionWithView:window
                          duration:0.3
                           options:UIViewAnimationOptionTransitionCrossDissolve
                        animations:nil
                        completion:nil];
    }
    
    + (UIStoryboard *)storyboardWithKey:(NSString *)key {
        NSBundle *bundle = [NSBundle mainBundle];
        NSString *storyboardName = [bundle objectForInfoDictionaryKey:key];
        return [UIStoryboard storyboardWithName:storyboardName bundle:bundle];
    }
    
    @end
    

    The original answer below, though I prefer my current approach

    Let’s express the app’s readiness to run the main vc with a boolean, something like:

    BOOL readyToRun = startupWorkIsDone && userIsLoggedIn;
    
    1. Create an AppStartupViewController and lay it out in app storyboard.
    2. Don’t drag any segue’s to it, and don’t make it the staring vc, just leave it floating somewhere.
    3. In the vc’s attributes inspector in storyboard, set it’s identifier as “AppStartupViewController”.

    In the AppStartupViewController.m, when the readyToRun conditions have been met, it can dismiss itself:

    self.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;   // your choice here from UIModalTransitionStyle
    [self dismissViewControllerAnimated:YES completion:nil];
    

    Now, whenever the app becomes active, it can check for readiness to run, and present the AppStartupViewController if it’s needed.
    In AppDelegate.h

    - (void)applicationDidBecomeActive:(UIApplication *)application {
    
        BOOL readyToRun = startupWorkIsDone && userIsLoggedIn;
    
        if (!readyToRun) {
            UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
            AppStartupViewController *startupVC = [storyboard instantiateViewControllerWithIdentifier:@"AppStartupViewController"];
    
            [self.window.rootViewController presentViewController:startupVC animated:NO completion:nil];
            // animate = NO because we don't want to see the mainVC's view
        }
    }
    

    That’s mostly the answer, but there is one hitch. Unfortunately the main vc gets loaded (that’s okay) and gets a viewWillAppear: message (not okay) before the AppStartupViewController is presented. It means we have to spread a little extra startup logic, like this, in MainViewController.m:

    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
    
        if (readyToRun) {
            // the view will appear stuff i would have done unconditionally before
        }
    }
    

    I hope this is helpful.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I need to clean up various Word 'smart' characters in user input, including but
Does anyone know how can I replace this 2 symbol below from the string

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.