简体   繁体   English

hidesBarsOnSwipe不起作用

[英]hidesBarsOnSwipe doesn't work

Have a following structure: 有以下结构:

UIViewController ( VC ) with some UIViews ( views ) on the top half of screen and UITableView ( tableView ) on the bottom half of screen. UIViewControllerVC )在屏幕的上半部分有一些UIViews视图 ),在屏幕的下半部分有UITableViewtableView )。 All are on the same hierarchy level within VC's view. 所有这些都在VC的视图中处于相同的层次结构级别。

VC is managed by UINavigationController . VCUINavigationController管理。

Auto-layout is off. 自动布局已关闭。 Using autoresizing masks. 使用自动调整遮罩。

dataSource and delegate methods are set up and works fine. dataSourcedelegate方法已设置并正常工作。

What I want to realize: 我想要实现的目标:

Hide a navigation bar when scroll up and show in after the scroll down. 向上滚动时隐藏导航栏,向下滚动后显示。

What I did: 我做了什么:

Since my project supports iOS8+ only, just setting: 由于我的项目仅支持iOS8 +,因此只需设置:

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    self.navigationController.hidesBarsOnSwipe = YES;
}

should be fine. 应该没事。

What I have: 我有的:

  1. Swiping up and down on the views hides and shows navigation bar respectively. 在视图上向上和向下滑动分别隐藏和显示导航栏。
  2. Scrolling tableView makes no sense. 滚动tableView毫无意义。

Spent some time on that and found that resizing tableView to make it match to vc's view solves the problem. 花了一些时间,发现调整tableView以使其与vc的视图匹配解决了问题。

Edit: 编辑:

  1. Is it mentioned somewhere in the docs that table view should be only full screen? 是否在文档中的某处提到表视图应该只是全屏?

  2. Found interesting thing: even if you didn't set hidesBarsOnTap to YES and try to tap on navigation area (ie when it's still hidden after swipe) - navigation bar will show after that. 发现有趣的事情:即使你没有将hidesBarsOnTap设置为YES并尝试点击导航区域(即滑动后仍然隐藏) - 导航栏将在此之后显示。 Very annoying if you have any UI elements in that area. 如果您在该区域中有任何UI元素,那会非常烦人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM