In my project initial entry point in storyboard is LoginViewController . If user login to app I always want to show main ViewController
of app by escaping LoginViewCntyroller , I did that following code in didFinishLaunchingWithOptions
method.
if ([[NSUserDefaults standardUserDefaults] boolForKey:IS_SIGNIN_CHECK])
dispatch_async(dispatch_get_main_queue(), ^(void){
[self showMainScreen];
});
-(void) showMainScreen
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:[NSBundle mainBundle]];
SWRevealViewController *viewController = (SWRevealViewController *)[storyboard instantiateViewControllerWithIdentifier:@"MainScreenViewID"];
[self.window makeKeyAndVisible];
[self.window.rootViewController presentViewController:viewController
animated:NO
completion:nil];
}
It's working fine. But problem is when it goes to MainViewController , it goes to LoginViewController for few seconds and then shows MainViewController . How to avoid that transition form LoginViewController to MainViewController ?
you are presenting your main screen through the LoginViewController
. Means first the LoginViewController view
will load and display to user and then it will redirect to main screen
there is no way to avoid it using this scheme.
But you can avoid it by setting your main screen
as rootViewController
of main window and it will work fine
if ([[NSUserDefaults standardUserDefaults] boolForKey:IS_SIGNIN_CHECK])
[self showMainScreen];
-(void) showMainScreen
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:[NSBundle mainBundle]];
SWRevealViewController *viewController = (SWRevealViewController *)[storyboard instantiateViewControllerWithIdentifier:@"MainScreenViewID"];
self.window.rootViewController = viewController;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.