My screen flow is as follow
Login -> Registration -> CarDetails
All 3 above screens are in navigation-controller, but users are not allowed to go back from Car-Details to Registration. To achieve it, I've
override func viewWillAppear(animated: Bool)
{
self.navigationItem.setHidesBackButton(true, animated:true);
}
in CarDetails view controller. So it hides the back button which automatically gets created if controller is in navigation-controller.
So far it is good.
After providing all detail user lands on Home Screen where I've slide out menu. From menu user can goto to CarDetail Screen as well (to update). That time instead of backButton I need slide-out menu button as left bar button. So I've created it using storyboard.
The problem is that it is getting displayed after Registration view as well. I need conditional show/hide functionality for it in Car-Details View.
I've hook for it as well, as following
override func viewDidLoad()
{
super.viewDidLoad()
if menuButtonVisibility
{
if self.revealViewController() != nil
{
menuButton.target = self.revealViewController()
menuButton.action = "revealToggle:"
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
}
}
else
{
}
menuButtonVisibility=true
}
I only need the line to put in else block.
Way 1: Touch “Settings” -> “Display” -> “Navigation bar” -> “Buttons” -> “Button layout”. Choose the pattern in “Hide navigation bar” -> When the app opens, the navigation bar will be automatically hidden and you can swipe up from the bottom corner of the screen to show it.
There is no way to "hide" a UIBarButtonItem you must remove it from the superView and add it back when you want to display it again. This is actually not true - the method described by Max works well.
You can hide it by disable the button & change it tintColor like that,
self.navigationItem.rightBarButtonItem?.isEnabled = false
self.navigationItem.rightBarButtonItem?.tintColor = UIColor.clear
do it right or left BarButtonItem whatever you preferred. Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With