Everything is happening programmatically. No Storyboard and The collection view's vc and the detailed vc are both inside a TabBarController.
I'm using a collection view and when I tap a cell in didSelectItem
I push on a detailed view controller. In the DetailedVC I hide the navigation controller. I called the below in viewDidLoad
and in viewWillAppear
both individually and cumulatively to try and keep it hidden:
navigationController?.isNavigationBarHidden = true
navigationController?.navigationBar.isHidden = true
navigationController?.setNavigationBarHidden(true, animated: false)
When the scene first appears the nav bar is hidden. The problem is when I swipe down on the DetailedVC the navigation bar comes down from the top of the screen with a swipe and it doesn't disappear. I discovered it by swiping down by mistake.
I press the navigation bar's back button and it works even though it should be hidden. The reason I hide it is because I have a video that plays at the very top of the DetailedVC so I use a custom button to pop back to the collection view. I also hide the status bar (similar to YouTube) but that stays hidden.
The DetailedVC is a regular view controller and it doesn't contain a table view or collection view so I'm confused as to why it's letting me swipe down and why the navigation bar won't stay hidden?
The collection view cell that pushes the DetailedVC on :
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let detailVC = DetailController()
navigationController?.pushViewController(detailVC, animated: true)
}
The DetailedVC:
class DetailController: UIViewController {
let customButton: UIButton = {
let button = UIButton(type: .system)
button.translatesAutoresizingMaskIntoConstraints = false
button.setTitle("< Back", for: .normal)
button.setTitleColor(UIColor.orange, for: .normal)
button.addTarget(self, action: #selector(handleCustomButton), for: .touchUpInside)
return button
}()
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
UIApplication.shared.isStatusBarHidden = true
// I tried all of these individually and cumulatively and the nav still shows when I swipe down
navigationController?.isNavigationBarHidden = true
navigationController?.navigationBar.isHidden = true
navigationController?.setNavigationBarHidden(true, animated: false)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
UIApplication.shared.isStatusBarHidden = false
}
@objc fileprivate func handleCustomButton()
navigationController?.popViewController(animated: true)
}
@objc fileprivate func configureButtonAnchors()
//customButton.leftAnchor...
}