CapsPageMenu 隐藏 TableView 上的 NavigationBar 从子 UIViewController 滚动不工作
CapsPageMenu Hide NavigationBar on TableView Scroll from child UIViewController not working
我正在使用以下库在我的应用程序中创建选项卡
https://github.com/PageMenu/PageMenu
子 UIViewControllers 有 tableview 我想从子视图控制器中隐藏 NavigationBar 但它不起作用
我尝试了以下操作
self.navigationController?.hidesBarsOnSwipe = true
在上面的代码中添加了子 UIViewController viewWillAppear 方法,并将 NavigationController 从父级传递给子级并调用了上面的代码,但它不起作用。
尝试了下面的另一种方法,在 tableview 滚动上添加了代码,但它在顶部留下了一些空 space
在选项卡下方
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)
}
}
设置子控制器视图框架使用,
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 class
的 func addPageAtIndex(_ index : Int) 内部
我正在使用以下库在我的应用程序中创建选项卡
https://github.com/PageMenu/PageMenu
子 UIViewControllers 有 tableview 我想从子视图控制器中隐藏 NavigationBar 但它不起作用
我尝试了以下操作
self.navigationController?.hidesBarsOnSwipe = true
在上面的代码中添加了子 UIViewController viewWillAppear 方法,并将 NavigationController 从父级传递给子级并调用了上面的代码,但它不起作用。
尝试了下面的另一种方法,在 tableview 滚动上添加了代码,但它在顶部留下了一些空 space 在选项卡下方
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)
}
}
设置子控制器视图框架使用,
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 class
的 func addPageAtIndex(_ index : Int) 内部