Create a Controller
1th way through the code controller
HKUIViewController.h
#import <UIKit/UIKit.h>@interface hkuiviewcontroller:uiviewcontroller@end
Hkuiviewcontroller.m
" HKUIViewController.h " @implementation Hkuiviewcontroller@end
Appdelegate.m
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions { = [[UIWindow alloc]init]; * HKVC = [[Hkuiviewcontroller alloc]init]; = [Uicolor redcolor]; = HKVC; [Self.window makekeyandvisible]; return YES;}
2nd way: Load the controller via storyboard.
1) Xcode Create storyboard
Storyboard, User interface, IOS, Xcode, create a new file named Test.storyboard.
2) Set Test.storyboard to initial View Controller
Check the is initial View Controller.
3) Drag a View controller into the Test.storyboard.
Set his class to Hkuiviewcontroller.
Appdelegate.m
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions { = [[UIWindow alloc]init]; *storyboard = [Uistoryboard storyboardwithname:@ "Test" Bundle:nil]; * HKVC = [Storyboard Instantiateinitialviewcontroller]; = HKVC; [Self.window makekeyandvisible]; return YES;}
The controller can also be loaded by means of a representation.
In Test.storyboard, the identity setting Storyboard ID is switch.
Appdelegate.m
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions {Self.window=[[UIWindow alloc]init]; Uistoryboard*storyboard = [Uistoryboard storyboardwithname:@"Test"Bundle:nil]; //Hkuiviewcontroller * HKVC = [Storyboard Instantiateinitialviewcontroller];Hkuiviewcontroller *HKVC = [Storyboard Instantiateviewcontrollerwithidentifier:@"Switch"]; Self.window.rootViewController=HKVC; [Self.window makekeyandvisible]; returnYES;}
Knowledge Points:
Commond + N Create a new storyboard
IOS Basics (22) Creating a controller