bdalziel bdalziel - 6 months ago 78
Objective-C Question

Table view in UIViewController doesn't get hidesBarsOnSwipe functionality

I have a table view as the first child of a regular UIViewController. I've tried adding the navigation controller's

gesture recognizer to both my view and table view, but no dice. In the snippet below, blah: is never getting called.

[self.navigationController setHidesBarsOnSwipe:YES];
[self.tableView addGestureRecognizer:self.navigationController.barHideOnSwipeGestureRecognizer];
[self.navigationController.barHideOnSwipeGestureRecognizer addTarget:self action:@selector(blah:)];

I feel like the
is the way to tap into this nice functionality when not using a top level scroll view controller (collection or table), but I can't figure out exactly how.


If want to hide navigationbar on swipe I mean when you scroll your tableview in up direction (goes to down) then

 self.navigationController.hidesBarsOnSwipe = YES;

is enough to achieve this. It will hides navigationbar and show it again on tap. Make sure you have set proper constraint to tableview. your constraint should be top,bottom,leading and trailing with constant of 0 with nearest neighbor.