Push / Pop View Controller With Navigation Bar from View Controller Without Navigation Bar
It is possible without hacking together a solution by yourself. Here is what you do:
Your root viewController:
@implementation ViewController
....
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
@end
And the pushed viewController:
@implementation SecondViewController
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:animated];
}
@end
This will do. It also keeps the interactive transition working ;)
I find it disturbing, however, that this type of functionality is not documented at all by apple. - You can also hide and show toolbars with these 'call-points' (inside viewWillAppear:)
EDIT
I just realized that this is the same code you wrote in your question. Please test it again. I am 100% sure that this works - I used this functionality in one of my apps, too.
Please also note that my code does use animated:animated
instead of your animated:NO
. This may be the crucial point here :)
How to go without navigation bar view controller to with navigation bar view controller in Swift
The only way how you can go from the view controller without navigation bar to view controller with one, is to present it modally.
So when you are creating that view controller, that you want to present in it's parent view controller, embed this target controller in navigation controller and then present that navigation controller, that contains your target view controller.
Swift 3
let targetViewController = UIViewController() // this is that controller, that you want to be embedded in navigation controller
let targetNavigationController = UINavigationController(rootViewController: targetViewController)
self.present(targetNavigationController, animated: true, completion: nil)
Show back button without navigation view controller
You can't achieve navigation functionality without using UINavigationController
. I mean you have to do all animation kind of stuff on your own, and I think that's not a good idea. Rather than that, you can use UINavigationController
, and if you don't want to show navigationBar
at some viewController, than do as follows for those view controllers.
override func viewWillApear() {
super.viewDidLoad()
self.navigationController?.isNavigationBarHidden = true
}
override func viewWillDisappear(animated: Bool) {
self.navigationController?.isNavigationBarHidden = false
}
iOS Push Navigation Controller, without a bar on the second view
give this a spin and see how it works for you.
in the destination view controller in viewWillAppear
- (void)viewWillAppear:(BOOL)animated {
[self.navigationController setNavigationBarHidden:YES animated:YES];
}
It actually has a cool effect and can be useful. in the viewWillAppear everything happens before the view is displayed so it takes away the strange artifacts.
be well
Is it possible to push a view controller without navigation controller?
You could use a UINavigationController and push it, and hide the navigationbar.
UINavigationController without navigation bar?
You should be able to do the following:
self.navigationController.navigationBar.isHidden = true //Swift 5
where self.navigationController is (obviously) an instance of UINavigationController. Seems to work for me, but I only briefly tested it before posting this.
Hide Navigation Bar for a View Controller
Use code:- Swift 5
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)
// Hide the Navigation Bar
self.navigationController?.setNavigationBarHidden(true, animated: true)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(true)
// Show the Navigation Bar
self.navigationController?.setNavigationBarHidden(false, animated: false)
}
I think you have done mistake in animated: true
Related Topics
How to Debug an Issue with a Release Mode Build in iOS
How to Tell If Blocks in Loop All Have Completed Executing
Detect Moment When Newline Starts in Uitextview
Clipstobounds Causes Uiimage to Not Display in iOS10 & Xcode 8
How to Add a Character at a Particular Index in String in Swift
Playing Video Inline in Ionic/Phonegap (Webkit-Playsinline Not Working)
Presenting Uialertcontroller from Uitableviewcell
Core Location Not Working in iOS 8
How to Use Mbprogresshud with Swift
Will Appstore Reviewers Allow Us to Use Dynamic Library in iOS8
iPad - Parsing an Extremely Huge JSON - File (Between 50 and 100 Mb)
Autolayout Aspect Ratio for Uiimageview/Uiview
Can Swift Closures Be Set to a Default Value When Used as a Parameter in a Function
Afnetworking - Do Not Cache Response