AppDelegate, rootViewController and presentViewController

前端 未结 6 2104
南方客
南方客 2020-11-27 15:38

I\'m doing the Facebook integration tutorial, I want to show my MainViewViewController if the user has a valid token for the current state otherwise I want to show LoginView

6条回答
  •  难免孤独
    2020-11-27 16:13

    I had the same issue. Based on the answer to this question, I added [self.window makeKeyAndVisible] just before presentViewController:animated:completion:, and that fixed it for me.

    In your case, showLoginView becomes

    - (void)showLoginView
    {
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
        LoginViewController *loginViewController = [storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
        [self.window makeKeyAndVisible];
        [self.window.rootViewController presentViewController:loginViewController animated:YES completion:NULL];
    }
    

提交回复
热议问题