Destroy Navigation bar and tab bar on specific view in swift - ios

I have one app to play video that build with swift. I play video on view AVPlayerViewController by story board. and inside the AVPlayViewController are contain with tab bar and navigation bar that I use on previous screen. during play the Video, when I push the done on the top left it will return to the first before navigation bar. and I want to remove the navigation bar and tab bar also from my AVPLayerViewController. is it possible to remove its? and during play the video, when push done, it will return to previous screen that I want, not go to first screen of app. Everyone, have any idea with this?.
Thank you.

Hide Navigation And Tab bar in PlayViewController viewDidLoad method.
func viewDidLoad() {
self.navigationController.navigationBar.hidden = true
self.tabBarController.tabBar.hidden = true
}
Show it in viewWillDisappear method:
func viewWillDisappear(){
self.navigationController.navigationBar.hidden = false
self.tabBarController.tabBar.hidden = false
}

Related

Swift 3 - how to hide Status Bar when using Over Full Screen

I'm developing a swift app and I can't find how to hide Status Bar when I use Over Full Screen presentation on my modal.
However, I put this line of code in my Modal View Controller :
override var prefersStatusBarHidden: Bool {
return true
}
And it is working if I create a segue which is not a modal, or if I create a segue which is a modal but not with Over Full Screen presentation.
I searched on internet how to fix it, and I found people who had the same problem but there had no solution.
Also, I can't change the color of my Status Bar when I'm using Over Full Screen option. I don't understand why? I think it's related.
Thanks for your help!
To hide the status bar when doing an over full screen modal, you need to set this in viewDidLoad:
override func viewDidLoad() {
super.viewDidLoad()
modalPresentationCapturesStatusBarAppearance = true
}
Then do the standard method to hide the status bar:
override var prefersStatusBarHidden: Bool {
return true
}
We can override preferredStatusBarStyle from individual view controller as you have done correctly.
Along with this, insert a new key named “View controller-based status bar appearance” and set the value to NO in your info.plist.
By disabling the “View controller-based status bar appearance”, you can set the status bar style by using the following code.
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; //objective-c
Hence it should solve "I can't change the color of my Status Bar when I'm using Over Full Screen option"

Navigation Based App With Tab Hidden

How to hide tabbar in Navigation Flow?
self.tabbarController.tabbar.hidden = true
This is not working. I called this from ViewWillAppear method.
Just check the Hide Bottom Bar on Push for your ViewController if you're using storyboard

Navigation controller's toolbar not being hidden after enabling hide on tap?

I have a navigation controller where I have enabled hide on tap.It hides at first when I tap on the screen but when I tap again,the nav bar hides but the toolbar does not hide at all and it is obstructing my view. I have already tried settoolbarhidden and toolbar.hidden properties but it does not work.How do I solve this?
EDIT : I need to hide it only on this screen,I need the toolbar for other screens so thats why I have enabled shows toolbar.
EDIT 2 : Let me frame my question better.
When I enter the view controller :
Both navbar and toolbar hides because I have set it to hidden which is good
When I tap the screen :
Both navbar and toolbar shows because I have set it this way in the previous view controller.(If possible,Can I only show/hide the navigationbar on tap not the toolbar?
And lastly when I tap it again to hide both bars :
The navigation bar hides but the toolbar does not go away? This is my problem.
As Per your question you want to show tool bar on a particular viewController. View Controller viewWillAppear Function Hide ToolBar and viewDidDisappear show your tool bar it will show on other view controllers.
" Please check the navigation controller checkbox its disable or not.After that set this on your view controller before your profile view controller "
override func viewWillAppear(animated: Bool) {
self.navigationController?.toolbarHidden = true;
}
override func viewDidDisappear(animated: Bool) {
self.navigationController?.toolbarHidden = false;
}
I think it will resolve your issue.
I had the same problem.
The hideBarsOnTap only work if you placed smth in it. So if it is empty it will stay.
You could just put a blank imageView or Label there for example.
Or if you want it completely blank, your only option is to put a tabGestureRecognizer on your View!

top navigation bar becomes visible when navigation back from push segue on iphone

I'm hiding the navigationbar on a certain view, and when the user presses a button on the view, i'm pushing it to the next view.
In the next view, I am not longer hiding the nav bar and as expected it becomes visible. When hitting back however, the navbar on the first view also becomes (somehow) visible.
I'm hiding the top navbar like this:
self.navigationController.navigationBar.hidden = YES;
And I'm making it visible like this:
self.navigationController.navigationBar.hidden = NO;
I wonder what could be wrong with this, as it's quite basic but somehow has a glitch.
In Parent VC's viewWillAppear method hide the navigation bar.
-(void)viewWillAppear:(BOOL)animated {
self.navigationController.navigationBar.hidden = YES;
}

Hide back button of navigation bar in Story board iOS

I would like to hide back button of navigation bar which is a part of Story board, I have tried different following code snippets in detail view button nothing seems to work for me.
self.navigationItem.hidesBackButton = YES;
self.navigationItem.backBarButtonItem=nil;
PS: I am also having tab bar along with navigation bar in my story board
Add this line in the viewDidLoad of your ViewController where you would like to hide the back bar button:
[self.navigationItem setHidesBackButton:YES];
Tested successfully in a storyboard project.
Try this
self.navigationItem.hidesBackButton= YES;
If you have added your own button to the navigationController and want to hide that as well (such as while editing text), its a two line process like this:
myViewController.navigationItem.leftBarButtonItem = nil;
myViewController.navigationItem.hidesBackButton=YES;
You can hide the entire navigationbar as follows:
self.navigationController.navigationBar.hidden = YES;
then in your storyboard you can add a navigation bar to your view controller.
The result is what you want but maybe users will be confused as to why they can't go back...
Its too late answer but may help others.
To hide back button you can do this :
self.navigationController.navigationItem.leftBarButtonItem.hidden = YES;
You can also try with :
self.navigationItem.leftBarButtonItem.hidden = YES;
This actually hides left BarButton and back button is on left side, too, unless you change programmatically.

Resources