我正在使用以下库在我的应用中创建标签
https://github.com/PageMenu/PageMenu
子 UIViewControllers 有 tableview 我想从 subview Controller 隐藏 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)
}
}
最佳答案
设置子 Controller View 框架使用,
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) 内部
关于ios - CapsPageMenu 隐藏 TableView 上的 NavigationBar 从子 UIViewController 滚动不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58950139/