1.ViewController
. m
- (void) viewdidload {[Super viewdidload]; Self.title=@"Hide Navigation bar"; UIButton*button =[UIButton Buttonwithtype:uibuttontypecustom]; Button.backgroundcolor=[Uicolor Lightgraycolor]; Button.frame= CGRectMake (Ten, -, -, -); [Button addtarget:self action: @selector (ButtonClick) forcontrolevents:uicontroleventtouchupinside]; [Self.view Addsubview:button]; Self.navigationcontroller.Delegate=Self ;}- (void) buttonclick{///Jump to Kkviewcontroller[Self Performseguewithidentifier:@"Pusht"Sender:nil];}
Head Agent
@interface Viewcontroller () <UINavigationControllerDelegate>
Proxy method
-(void) Navigationcontroller: (Uinavigationcontroller *) Navigationcontroller Willshowviewcontroller: ( Uiviewcontroller *) Viewcontroller animated: (BOOL) animated { [Self.navigationcontroller Setnavigationbarhidden: [self hiddenbarvc:viewcontroller] animated:animated];} -(BOOL) HIDDENBARVC: (Uiviewcontroller *) viewcontroller { = NO; if class ]]) { = YES; } return Needhidenaivgaionbar;}
2.KKViewController (target Viewcontroller)
Create a new Kkviewcontroller
. h
ID popdelegate;
. m
- (void) viewdidload {[Super viewdidload]; Self.title=@"a second page"; [Self popset];}- (void) popset{_popdelegate= Self.navigationController.interactivePopGestureRecognizer.Delegate; SEL Action= Nsselectorfromstring (@"handlenavigationtransition:"); Uipangesturerecognizer*poppangesture =[[Uipangesturerecognizer alloc] initWithTarget:self.popDelegate action:action]; Poppangesture.maximumnumberoftouches=1; Poppangesture.Delegate=Self ; [Self.view addgesturerecognizer:poppangesture];}
Head Agent
@interface Kkviewcontroller () <UIGestureRecognizerDelegate>
Gesture Proxy method
-(BOOL) Gesturerecognizershouldbegin: (Uipangesturerecognizer *) gesturerecognizer{///"Here are two ways to write a"///Full Screen DragCgpoint Tragpoint =[Gesturerecognizer TranslationInView:gestureRecognizer.view]; if(Tragpoint.x <=0){ returnNO; } Else{ if(Self.navigationController.viewControllers.count <=1){ returnNO; } Else{ returnYES; } } // ///local Allow drag//cgpoint tragpoint = [Gesturerecognizer LocationInView:gestureRecognizer.view];//NSLog (@ "x=%f;y=%f", tragpoint.x,tragpoint.y);//if (Tragpoint.x >) {///Drag the range//return NO;// }//else{//if (self.navigationController.viewControllers.count <= 1) {//return NO;// }//else{//return YES;// }// }}
ios-hidden Navigationbar "navigation bar seamless and sleek hidden"