How do I access my viewController from my appDelegate? iOS

后端 未结 6 2175
遇见更好的自我
遇见更好的自我 2020-11-28 05:31

I have an iOS app I created as a \"view-based app\" in xCode. I have only one viewController, but it is displayed automatically, and I see no code that ties it to my appDel

6条回答
  •  無奈伤痛
    2020-11-28 05:38

    If you want to get any other UIViewController, not just the rootViewController:

    UIWindow *window=[UIApplication sharedApplication].keyWindow;
    UIViewController *root = [window rootViewController];
    
    UIStoryboard *storyboard = root.storyboard;
    CustomViewController *vcc =(CustomViewController *) [storyboard instantiateViewControllerWithIdentifier:@"storyBoardID"];
    

提交回复
热议问题