【问题标题】:CapsPageMenu Hide NavigationBar on TableView Scroll from child UIViewController not workingCapsPageMenu 隐藏 TableView 上的 NavigationBar 从子 UIViewController 滚动不起作用
【发布时间】:2020-03-15 22:08:37
【问题描述】:

我正在使用以下库在我的应用中创建标签

https://github.com/PageMenu/PageMenu

子 UIViewControllers 有 tableview 我想从子视图控制器中隐藏 NavigationBar 但它不起作用

我已经尝试过以下事情

self.navigationController?.hidesBarsOnSwipe = true

在上面的代码中添加了子 UIViewController viewWillAppear 方法,并将 NavigationController 从父级传递给子级并调用了上面的代码,但它不起作用。

尝试了下面的另一种方法,在 tableview 滚动上添加了代码,但它在顶部留下了一些空白空间 标签下方

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


    if(velocity.y>0) {

        UIView.animate(withDuration: 0.5, delay: 0, options: UIView.AnimationOptions(), animations: {

            self.navigateCont.setNavigationBarHidden(true, animated: true)

        }, completion: nil)

    } else {

        UIView.animate(withDuration: 0.5, delay: 0, options: UIView.AnimationOptions(), animations: {
            self.navigateCont.setNavigationBarHidden(false, animated: true)


        }, completion: nil)
    }
}

【问题讨论】:

    标签: ios swift uitableview uinavigationcontroller uinavigationbar


    【解决方案1】:

    使用设置子控制器视图框架,

    newVC.view.frame = CGRect(x: self.view.frame.width * CGFloat(index), y: menuHeight, width: self.view.frame.width, height: self.view.frame.height)
    

    相反,

    newVC.view.frame = CGRect(x: self.view.frame.width * CGFloat(index), y: menuHeight, width: self.view.frame.width, height: self.view.frame.height-menuHeight)
    

    CAPSPageMenu 类

    的 func addPageAtIndex(_ index : Int) 内部

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-30
      • 2018-02-21
      相关资源
      最近更新 更多