[Basic iOS control and basic ios Control
A. Requirements1. Convert the navigation bar like QQ, top, or bottom windows 2. Add corresponding content to each pageB. UITabBarController1. basic concepts: (1) content height before iOS7: screen height-Status Bar Height 44-bottom navigation bar height after 49iOS7 and content height for the entire Screen 1-(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) launchOptions {2 // Override point for customization after application launch. 3 4 // set window 5 self. window = [[UIWindow alloc] init]; 6 self. window. frame = [[UIScreen mainScreen] bounds]; 7 self. window. backgroundColor = [UIColor grayColor]; 8 [self. window makeKeyAndVisible]; 9 10 11 // set a UITabBarController12 UITabBarController * tabBarController = [[UITabBarController alloc] init]; 13 self. window. rootViewController = tabBarController; 14 15 // Add sub-controller 16 UIViewController * c1 = [[UIViewController alloc] init]; 17 c1.view. backgroundColor = [UIColor redColor]; 18 // [tabBarController addChildViewController: c1]; 19 20 UIViewController * c2 = [[UIViewController alloc] init]; 21 c2.view. backgroundColor = [UIColor blueColor]; 22 // [tabBarController addChildViewController: c2]; 23 24 UIViewController * c3 = [[UIViewController alloc] init]; 25 c3.view. backgroundColor = [UIColor greenColor]; 26 27 tabBarController. viewControllers = @ [c1, c2, c3]; 28 29 30 return YES; 31}1-(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) launchOptions {2 // Override point for customization after application launch. 3 4 // set window 5 self. window = [[UIWindow alloc] init]; 6 self. window. frame = [[UIScreen mainScreen] bounds]; 7 self. window. backgroundColor = [UIColor grayColor]; 8 [self. window makeKeyAndVisible]; 9 10 11 // set a UITabBarController12 UITabBarController * tabBarController = [[UITabBarController alloc] init]; 13 self. window. rootViewController = tabBarController; 14 15 // Add sub-controller 16 UIViewController * c1 = [[UIViewController alloc] init]; 17 c1.view. backgroundColor = [UIColor redColor]; 18 c1.tabBarItem. title = @ "red"; 19 // [tabBarController addChildViewController: c1]; 20 21 UIViewController * c2 = [[UIViewController alloc] init]; 22 c2.view. backgroundColor = [UIColor blueColor]; 23 c2.tabBarItem. title = @ "blue"; 24 // [tabBarController addChildViewController: c2]; 25 26 UIViewController * c3 = [[UIViewController alloc] init]; 27 c3.view. backgroundColor = [UIColor greenColor]; 28 c3.tabBarItem. title = @ "green"; 29 30 tabBarController. viewControllers = @ [c1, c2, c3]; 31 32 33 return YES; 34}1-(void) viewDidLoad {2 [super viewDidLoad]; 3 NSLog (@ "% @-viewDidLoad", self. class); 4} 5 6-(void) viewWillAppear :( BOOL) animated {7 [super viewWillAppear: animated]; 8 NSLog (@ "% @-viewWillAppear", self. class); 9} 10 11-(void) viewDidAppear :( BOOL) animated {12 [super viewDidAppear: animated]; 13 NSLog (@ "% @-viewDidAppear", self. class); 14} 15 16-(void) viewWillDisappear :( BOOL) animated {17 [super viewWillDisappear: animated]; 18 NSLog (@ "% @-viewWillDisappear", self. class); 19} 20 21-(void) viewDidDisappear :( BOOL) animated {22 [super viewDidDisappear: animated]; 23 NSLog (@ "% @-viewDidDisappear", self. class); 24} 25 26 27-(void) didReceiveMemoryWarning {28 [super didreceivemorywarning]; 29 NSLog (@ "% @-didreceivemorywarning", self. class); 30} 31 32-(void) viewWillUnload {33 [super viewWillUnload]; 34 NSLog (@ "% @-viewWillUnload", self. class); 35} 36 37-(void) viewDidUnload {38 [super viewDidUnload]; 39 NSLog (@ "% @-viewDidUnload", self. class); 40}(2) lifecycle of two subcontrollers. a. The first subcontroller view is displayed.21:11:44. 338 UITabBarControllerByStoryboard [22567: 590996] OneViewController-viewDidLoad
21:11:44. 340 UITabBarControllerByStoryboard [22567: 590996] OneViewController-viewWillAppear21:11:44. 407 UITabBarControllerByStoryboard [22567: 590996] OneViewController-viewDidAppearB. Switch to the second controller view.21:12:10. 042 UITabBarControllerByStoryboard [22567: 590996] TwoViewController-viewDidLoad
21:12:10. 042 UITabBarControllerByStoryboard [22567: 590996] TwoViewController-viewWillAppear
21:12:10. 042 UITabBarControllerByStoryboard [22567: 590996] OneViewController-viewWillDisappear
21:12:10. 054 UITabBarControllerByStoryboard [22567: 590996] OneViewController-viewDidDisappear21:12:10. 055 UITabBarControllerByStoryboard [22567: 590996] TwoViewController-viewDidAppearC. App frameworkPackage A NavigationController before each sub-controller.