iOS Present modal view controller on startup without flash iOS Present modal view controller on startup without flash ios ios

iOS Present modal view controller on startup without flash


All presentViewController methods require the presenting view controller to have appeared first. In order to hide the root VC an overlay must be presented. The Launch Screen can continued to be presented on the window until the presentation has completed and then fadeout the overlay.

    UIView* overlayView = [[[UINib nibWithNibName:@"LaunchScreen" bundle:nil] instantiateWithOwner:nil options:nil] firstObject];overlayView.frame = self.window.rootViewController.view.bounds;overlayView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;UIStoryboard *storyboard = self.window.rootViewController.storyboard;TutorialViewController* tutorialViewController = [storyboard instantiateViewControllerWithIdentifier:@"tutorial"];tutorialViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;[self.window makeKeyAndVisible];[self.window addSubview:overlayView];[self.window.rootViewController presentViewController:tutorialViewController animated:NO completion:^{    NSLog(@"displaying");    [UIView animateWithDuration:0.5 animations:^{        overlayView.alpha = 0;    } completion:^(BOOL finished) {        [overlayView removeFromSuperview];    }];}];


Bruce's upvoted answer in Swift 3:

if let vc = window?.rootViewController?.storyboard?.instantiateViewController(withIdentifier: "LOGIN")    {        let launch = UIStoryboard(name: "LaunchScreen", bundle: nil).instantiateInitialViewController()!        launch.view.frame = vc.view.bounds        launch.view.autoresizingMask = [UIViewAutoresizing.flexibleWidth, UIViewAutoresizing.flexibleHeight]        window?.makeKeyAndVisible()        window?.addSubview(launch.view)        //Using DispatchQueue to prevent "Unbalanced calls to begin/end appearance transitions"        DispatchQueue.global().async {            // Bounce back to the main thread to update the UI            DispatchQueue.main.async {                self.window?.rootViewController?.present(vc, animated: false, completion: {                    UIView.animate(withDuration: 0.5, animations: {                        launch.view.alpha = 0                    }, completion: { (_) in                        launch.view.removeFromSuperview()                    })                })            }        }    }


may be your can use the "childViewController"

UIStoryboard *storyboard = self.window.rootViewController.storyboard;TutorialViewController* tutorialViewController = [storyboard instantiateViewControllerWithIdentifier:@"tutorial"];[self.window addSubview: tutorialViewController.view];[self.window.rootViewController addChildViewController: tutorialViewController];[self.window makeKeyAndVisible];

When you need to dismiss your tutor, you can remove its view from the superview. Also you can add some animation on the view by setting the alpha property.Hope helpful:)