Swift Calling Setnavigationbarhidden But View Wont Move to Top

Swift calling setNavigationBarHidden but view wont move to top

Try this code...

Note: This is a simple approach for your problem. If you want more custom look navBar and status bar look .You should read my previous comment...

Set navigation controller property hidesBarsOnSwipe to true

     override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)

navigationController?.hidesBarsOnSwipe = true

}

setNavigationBarHidden not working from other class (Swift 3.0)

Note: Below answer based on the conversation between the question owner and myself.

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

if(velocity.y>0) {

UIView.animate(withDuration: 2.5, delay: 0, options: UIViewAnimationOptions(), animations: {
self.navigationController?.setNavigationBarHidden(true, animated: true)
}, completion: nil)

} else {
UIView.animate(withDuration: 2.5, delay: 0, options: UIViewAnimationOptions(), animations: {
self.navigationController?.setNavigationBarHidden(false, animated: true)
}, completion: nil)
}

No Swipe Back when hiding Navigation Bar in UINavigationController

A hack that is working is to set the interactivePopGestureRecognizer's delegate of the UINavigationController to nil like this:

[self.navigationController.interactivePopGestureRecognizer setDelegate:nil];

But in some situations it could create strange effects.

swift hiding navigationbar and adding a custom back button not sure if I am doing it right

Simulated metrics are just that - simulated. They have no effect on the application.
In the second VC viewDidLoad put

self.navigationController?.setNavigationBarHidden(true, animated: false)

How to hide a navigation bar from first ViewController in Swift?

If you know that all other views should have the bar visible, you could use viewWillDisappear to set it to visible again.

In Swift:

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.setNavigationBarHidden(true, animated: animated)
}

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
navigationController?.setNavigationBarHidden(false, animated: animated)
}


Related Topics



Leave a reply



Submit