That's what I did, usually.
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions { Override point for customization after application launch. Viewcontroller *FIRSTVC = [[Viewcontroller alloc] init]; Uinavigationcontroller *navicontroller = [[Uinavigationcontroller alloc] INITWITHROOTVIEWCONTROLLER:FIRSTVC]; Self.window.rootViewController = Navicontroller; Self.window.backgroundColor = [Uicolor whitecolor]; [Self.window makekeyandvisible];
However, after running, Uinavigationcontroller did appear as the root view of Windows, but the controls in the FIRSTVC were not displayed, a blank
It turns out that it is not possible to alloc the FIRSTVC directly, but to load it from the storyboard, I change it as follows:
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions { Override point for customization after application launch. Uistoryboard *storyboard = [Uistoryboard storyboardwithname:@ "Main_" bundle:nil]; Viewcontroller *FIRSTVC = [StoryBoard instantiateviewcontrollerwithidentifier:@ "MainView"]; Uinavigationcontroller *navicontroller = [[Uinavigationcontroller alloc] INITWITHROOTVIEWCONTROLLER:FIRSTVC]; Self.window.rootViewController = Navicontroller; Self.window.backgroundColor = [Uicolor whitecolor]; [Self.window makekeyandvisible]; return YES;}
I have seen a lot of code examples are like the former directly alloc loading can, but I do not here, it must be loaded from the storyboard, I did not notice where the big God told
iOS Development Notes-iOS9.3 Uinavigationcontroller Add a workaround for Viewcontroller controls that are not displayed in storyboard