AppDelegate, rootViewController and presentViewController

前端 未结 6 2102
南方客
南方客 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:16

    You can launch a new viewController from root like this in Objective-C

    UIViewController *presenter = ((AppDelegate *)[[UIApplication sharedApplication] delegate]).window.rootViewController;
    
    [presenter presentViewController:yourViewController animated:YES completion:nil];
    

    Don't forget to add this:

    #import "AppDelegate.h"
    

提交回复
热议问题