IOS Learning NSNavigationController1 Parent-child page Jump navigation bar Hide __ios

Source: Internet
Author: User

@implementation Appdelegate

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions {

Override point for customization after application launch.

SELF.HOMEVC = [[Homeviewcontroller alloc]init];

Uinavigationcontroller *navigation = [[Uinavigationcontroller ALLOC]INITWITHROOTVIEWCONTROLLER:SELF.HOMEVC];

Self.window.rootViewController = navigation;

return YES;

}




#import "HomeViewController.h"


@interface Homeviewcontroller ()


@end


@implementation Homeviewcontroller


-(void) loadview{

UIView *baseview = [[UIView alloc]initwithframe:[[uiscreen Mainscreen]applicationframe]];

Self.view = Baseview;

Baseview.backgroundcolor = [Uicolor Purplecolor];


}


-(void) Viewdidload {

[Super Viewdidload];

UIButton *button = [[UIButton alloc]initwithframe:cgrectmake (100, 100, 200, 40)];

Button.layer.cornerRadius = 8;

Button.backgroundcolor = [Uicolor Greencolor];

[Button settitle:@ "push" forstate:uicontrolstatenormal];

[Button addtarget:self action: @selector (PUSHTV) forcontrolevents:uicontroleventtouchupinside];

[Self.view Addsubview:button];

}


-(void) pushtv{

Uiviewcontroller *SECONDTV = [[Secondviewcontroller alloc]init];

Jump to sub page

[Self.navigationcontroller Pushviewcontroller:secondtv Animated:yes];

}


-(void) didreceivememorywarning {

[Super didreceivememorywarning];

}


@end





#import "SecondViewController.h"


@interface Secondviewcontroller ()


@end


@implementation Secondviewcontroller


-(void) Viewdidload {

[Super Viewdidload];

Do no additional setup after loading the view.

UIButton *button = [[UIButton alloc]initwithframe:cgrectmake (100, 100, 200, 40)];

Button.layer.cornerRadius = 8;

Button.backgroundcolor = [Uicolor Purplecolor];

[Button settitle:@ "second" forstate:uicontrolstatenormal];

[Button addtarget:self action: @selector (BACKTV) forcontrolevents:uicontroleventtouchupinside];

[Self.view Addsubview:button];

UIButton *savebtn = [[UIButton alloc]initwithframe:cgrectmake (125, 200, 150, 40)];

SaveBtn.layer.cornerRadius = 8;

Savebtn.backgroundcolor = [Uicolor Orangecolor];

[Savebtn settitle:@ "Save" forstate:uicontrolstatenormal];

[Savebtn addtarget:self Action: @selector (Saveclick) forcontrolevents:uicontroleventtouchupinside];

[Self.view ADDSUBVIEW:SAVEBTN];

}


-(void) backtv{

Navigation bar Hide

if (Self.navigationController.toolbarHidden) {

[Self.navigationcontroller Settoolbarhidden:no Animated:yes];

[Self.navigationcontroller Setnavigationbarhidden:no Animated:yes];

}else

{

[Self.navigationcontroller Settoolbarhidden:yes Animated:yes];

[Self.navigationcontroller Setnavigationbarhidden:yes Animated:yes];

}


}


-(void) saveclick{

Back to the main face

[Self.navigationcontroller Poptorootviewcontrolleranimated:yes];


}

-(void) didreceivememorywarning {

[Super didreceivememorywarning];

}


@end


Related Article

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.