presentModalViewController in viewDidLoad on first launch

I’ve been searching around but unfortunately have had no luck.

My app requires the user to sign in/sign up the first time he or she launches the app. I know how to determine first launch (using NSUserDefaults) but whenever I try to present the modal containing the sign in/ sign up controls, nothing happens.

  • iOS - Math help - base image zooms with pinch gesture need overlaid images adjust X/Y coords relative
  • How to create Objective-C Protocol in new version of XCode Version 6.0.1 (6A317) for iOS
  • Getting safari history from phone
  • How to get rid of this “points” between my lines when I am drawing?
  • Defining a property in iOS class extension
  • Imitate Facebook hide/show expanding/contracting Navigation Bar
  • Here’s what I have:

    -(void)viewDidLoad {
        [self showLogin];
        [super viewDidLoad];
    -(void)showLogin {    
        FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"AccountView" bundle:nil];
        controller.delegate = self;
        controller.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
        [self presentModalViewController:controller animated:YES];
        [controller release];

    However, nothing happens. The main view just loads as normal. Any help is greatly appreciated.


    4 Solutions Collect From Internet About “presentModalViewController in viewDidLoad on first launch”


    Fixed simply by using..


    instead of


    Thanks anyway!


    I had the same issue and ended up using viewDidAppear as well. The only problem with the viewDidAppear approach is that if you load other UIViewControllers on top, then reshow the base, then your setup code gets called over and over. I ended up having to add a boolean value (initialised to YES) to this view controller and check that value before deciding what to do. Hope this helps someone…

    - (void)viewDidAppear:(BOOL)animated
        [super viewDidAppear:(BOOL)animated];
            justLaunched = NO;
                [self displayMainView];
                [self displaySetupView];

    How about using performSelector:withObject:afterDelay in the viewDidLoad function? That’s how I do it, with a short delay of 0.1s.

    And invoking this in the viewDidLoad isn’t very safe : the sequence viewDidLoad / viewDidUnload can occur at runtime when the iPhone needs to release some views in order to get back some free memory.

    The side effect of such sequence would be that your login controller would be shown…

    As you said the viewDidAppear looks better but not simply put it at the end of the appDidFinishedLaunching the delegate of your UIApplication?