I have hidden the navigation bar and status bar, now the screen hardness to go back won't work, is this typical?

I am wondering if I set the navigationBar to hidden

and also hide the status bar, my view controller no longer responds to screen hardness to expose the view controller.

Is this the expected behavior? I tried to include interactivePopGestureRecognizer

in viewDidLoad

after I hide the navbar, but it still doesn't work.

+3


source to share


3 answers


[self.navigationController.navigationBar setHidden:YES];<--doesn't remove pop gesture

[self.navigationController setNavigationBarHidden:YES];<-- disables pop gesture

      

Just use the first option and in your root controller the viewDidAppear method uses:



[self.navigationController.navigationBar setHidden:NO];

      

+8


source


Are you sure you did everything right? I put together an example that seems to work for me. All I did was do navigationController.navigationBar.hidden = YES

and[[UIApplication sharedApplication] setStatusBarHidden:YES]

-edit -



Upon closer inspection, it looks like there are two different properties in the UINavigationController. There is navigationBar

, which is the UINavigationBar view, and there is navigationBarHidden

, which is boolean. When you set the parameter navigationBarHidden

to true, the swipe gesture stops working. But if you've set the actual view to be hidden with navigationBar.hidden

, then the gesture still works. Check out the sample Git repository.

+2


source


Very simple job:

Associate a gesture method with a navigation button. Let the current view controller be a gesture recognizer (self) using the popThisViewController selector. Then set the gesture recognizer to the view the user will swipe. Don't forget to add your action back

change the added gesture gesture to link to other encoders that don't know

A cleaner code would look like this:

    UISwipeGestureRecognizer *gesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(goBack:)];
    gesture.numberOfTouchesRequired = 1;
    gesture.direction = UISwipeGestureRecognizerDirectionRight;
    [self.view addGestureRecognizer:swipeRight];
}

-(IBAction)goBack:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

      

0


source







All Articles