I have a table view as the first child of a regular UIViewController. I've tried adding the navigation controller's barHideOnSwipeGestureRecognizer
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 barHideOnSwipeGestureRecognizer
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 you want to hide navigationbar
on swipe, meaning when you scroll your tableview
in upward direction (goes to down) then
self.navigationController.hidesBarsOnSwipe = YES;
is enough to achieve this. It will hide the 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
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.