Combined use of column controllers and navigation controllers-the mainstream framework

Source: Internet
Author: User
Tags uikit

Combined use of column controllers and navigation controllers-the mainstream framework

Now some of the mainstream frameworks are basically used by the column controller and the navigation controller

The navigation controller is responsible for horizontal switching

Column controller is the control of vertical switching

We should study some of the main framework of the implementation of the principle of ascension on this basis will be faster

This is just for everyone to throw bricks, I hope you can learn some knowledge

What we call a stack controller-essentially an array for managing each page

Directly on the code:

  appdelegate.h//  88888-tabbar#import <UIKit/UIKit.h> @interface Appdelegate:uiresponder < Uiapplicationdelegate> @property (Strong, nonatomic) UIWindow *window; @end

appdelegate.m//88888-tabbar#import "AppDelegate.h" #import "GPoneController.h" #import "GPTwoController.h" @ Interface Appdelegate () @end @implementation appdelegate-(BOOL) Application: (UIApplication *) application Didfinishlaunchingwithoptions: (nsdictionary *) launchoptions {Self.window = [[UIWindow alloc]initwithframe:[uiscree        n Mainscreen].bounds];        Uitabbarcontroller *tab = [[Uitabbarcontroller alloc]init];    Gponecontroller *one = [[Gponecontroller alloc]init];        One.view.backgroundColor = [Uicolor Bluecolor];    Uinavigationcontroller *nvcone = [[Uinavigationcontroller alloc]initwithrootviewcontroller:one];         NvcOne.tabBarItem.title = @ "Yours";    Gptwocontroller *two = [[Gptwocontroller alloc]init];        Two.view.backgroundColor = [Uicolor Greencolor];        Uinavigationcontroller *nvctwo = [[Uinavigationcontroller alloc]initwithrootviewcontroller:two];            NvcTwo.tabBarItem.title = @ "my";        Nsarray *controllers = @[nvcone,nvctwo]; TaB.viewcontrollers = controllers;                Self.window.rootViewController = tab;    [Self.window makekeyandvisible];    Override point for customization after application launch. return YES;} -(void) Applicationwillresignactive: (uiapplication *) application {//Sent when the application was about to move from a Ctive to inactive state. This can occur for certain types of temporary interruptions (such as a incoming phone call or SMS message) or when the US    Er quits the application and it begins the transition to the background state. Use the This method to the pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should with this method to pause the game.} -(void) Applicationdidenterbackground: (uiapplication *) application {//Use the method to release shared resources, SA  ve user data, invalidate timers, and store enough application state information to restore your application    State-in-case it is terminated later. If Your application supports background execution, this method is called instead of Applicationwillterminate:when the user Quits.} -(void) Applicationwillenterforeground: (uiapplication *) application {//called as part of the transition from the back Ground to the inactive state; Here's can undo many of the changes made on entering the background.} -(void) Applicationdidbecomeactive: (uiapplication *) application {//Restart any tasks this were paused (or not yet STA rted) While the application was inactive. If the application is previously in the background, optionally refresh the user interface.} -(void) Applicationwillterminate: (uiapplication *) application {//called when the application was about to terminate. S Ave data if appropriate. See also Applicationdidenterbackground:.} @end

  gponecontroller.h//  88888-tabbar#import <UIKit/UIKit.h> @interface Gponecontroller: Uiviewcontroller@end

gponecontroller.m//88888-tabbar#import "GPoneController.h" #import "GPBookListController.h" @interface        Gponecontroller () @end @implementation gponecontroller-(void) viewdidload {[Super viewdidload];    UIButton *btn = [UIButton buttonwithtype:uibuttontypecustom];    Btn.frame = CGRectMake (0, 100, 200, 30);    [Btn settitle:@ "My Library" forstate:uicontrolstatenormal];    Btn.backgroundcolor = [Uicolor Redcolor];    [Btn addtarget:self Action: @selector (Btntouch) forcontrolevents:uicontroleventtouchupinside];                  [Self.view ADDSUBVIEW:BTN]; Do any additional setup after loading the view.}    -(void) btntouch{gpbooklistcontroller *book = [[Gpbooklistcontroller alloc]init];        Book.view.backgroundColor = [Uicolor Graycolor];    [Self.navigationcontroller Pushviewcontroller:book Animated:yes]; NSLog (@ "Btntouch");}    -(void) didreceivememorywarning {[Super didreceivememorywarning]; Dispose of any resources the can be recreated.} /* #pragma mark-navigation//in a storyboard-based application, you'll often want to do a little preparation before navigation-(void) Preparefo Rsegue: (Uistoryboardsegue *) Segue Sender: (ID) Sender {//Get the new view controller using [Segue Destinationviewcontro    Ller]. Pass the selected object to the new view Controller.} */@end

  gptwocontroller.h//  88888-tabbar#import <UIKit/UIKit.h> @interface Gptwocontroller: Uiviewcontroller@end

  gptwocontroller.m//  88888-tabbar#import "GPTwoController.h" @interface Gptwocontroller () @ End@implementation gptwocontroller-(void) viewdidload {    [super viewdidload];    Do any additional setup after loading the view.} -(void) didreceivememorywarning {    [super didreceivememorywarning];    Dispose of any resources the can be recreated.} /* #pragma mark-navigation//in a storyboard-based application, you'll often want to do a little preparation before Nav igation-(void) Prepareforsegue: (Uistoryboardsegue *) Segue Sender: (ID) Sender {    //Get The new view controller using [s] Egue Destinationviewcontroller].    Pass the selected object to the new view Controller.} */@end

//

GPBookListController.h

88888-tabbar


#import <UIKit/UIKit.h>


@interface Gpbooklistcontroller:Uiviewcontroller


@end


gpbooklistcontroller.m//88888-tabbar#import "GPBookListController.h" #import "GPnextController.h" @interface    Gpbooklistcontroller () @end @implementation gpbooklistcontroller-(void) viewdidload {[Super viewdidload];    UIButton *btn = [UIButton buttonwithtype:uibuttontypecustom];    Btn.frame = CGRectMake (0, 200, 100, 30);    [Btn settitle:@] Jump to your page "Forstate:uicontrolstatenormal";    Btn.backgroundcolor = [Uicolor Orangecolor];    [Self.view ADDSUBVIEW:BTN];        [Btn addtarget:self Action: @selector (Btntouch) forcontrolevents:uicontroleventtouchupinside]; Do any additional setup after loading the view.}        -(void) btntouch{gpnextcontroller *NVC = [[Gpnextcontroller alloc]init]; [Self.navigationcontroller PUSHVIEWCONTROLLER:NVC animated:yes];}    -(void) didreceivememorywarning {[Super didreceivememorywarning]; Dispose of any resources the can be recreated.} /* #pragma mark-navigation//in a storyboard-based application, you'll often want to do a little pReparation before navigation-(void) Prepareforsegue: (Uistoryboardsegue *) Segue Sender: (ID) Sender {//Get the new view    Controller using [Segue Destinationviewcontroller]. Pass the selected object to the new view Controller.} */@end

  gpnextcontroller.h//  88888-tabbar//#import <UIKit/UIKit.h> @interface Gpnextcontroller: Uiviewcontroller@end

gpnextcontroller.m//88888-tabbar#import "GPnextController.h" @interface Gpnextcontroller () @end @implementation        gpnextcontroller-(void) viewdidload {[Super viewdidload];        Self.view.backgroundColor = [Uicolor Purplecolor];        UIButton *btn = [UIButton buttonwithtype:uibuttontypecustom];        Btn.frame = CGRectMake (0,200, 200, 30);        [BTN settitle:@ "setting personal information" forstate:uicontrolstatenormal];        Btn.backgroundcolor = [Uicolor Cyancolor];        [Self.view ADDSUBVIEW:BTN];        [Btn addtarget:self Action: @selector (Btntouch) forcontrolevents:uicontroleventtouchupinside]; Do any additional setup after loading the view.} -(void) btntouch{NSLog (@ "set success");}    -(void) didreceivememorywarning {[Super didreceivememorywarning]; Dispose of any resources the can be recreated.} /* #pragma mark-navigation//in a storyboard-based application, you'll often want to do a little preparation before Nav igation-(void) Prepareforsegue: (Uistoryboardsegue *) Segue Sender: (ID) Sender {//Get the new view controller using [Segue Destinationviewcontroller]. Pass the selected object to the new view Controller.} */@end


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Combined use of column controllers and navigation controllers-the mainstream framework

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.