导航栏一旦隐藏(滑动)就不会回来 [英] Navigation Bar doesn't come back once it hides (swipe)

查看:28
本文介绍了导航栏一旦隐藏(滑动)就不会回来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个带有 TableView 的 ViewController,并在其中嵌入了一个 NavigationController.我也设置了约束.向下滑动时,导航栏隐藏.一切看起来都很好.

I created a ViewController with TableView inside it and embedded it a NavigationController. I also set the constraints. On Swipe down, Navigation Bar hides. Everything seems fine.

唯一的问题是在向上滑动时,导航栏不会回来.

The only problem is that on Swipe Up, the Navigation Bar doesn't come back.

如果我使用同一个 TableView 和一个 TableViewController 而不是 ViewController(从同一个导航控制器嵌入),导航栏会回来.

If I use the same TableView with a TableViewController instead of ViewController (embedded from the same Navigation Controller), the Navigation Bar does comes back.

对于那些想知道为什么我不只使用 TableViewController 的人,因为我需要取消选中 Adjust Scroll View Insets 以获得一些令人不安的 错误.

推荐答案

为了解决这个问题,我使用了 scrollViewWillEndDragging 并检测到 Going Down &往上走

To solve the issue, I used scrollViewWillEndDragging and detected Going Down & Going Up

func scrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {

   if targetContentOffset.memory.y < scrollView.contentOffset.y {
       // UP
   } else {
       // DOWN
   }
}

这篇关于导航栏一旦隐藏(滑动)就不会回来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆