UINAVIGATIONCONTROLLER doesn't show back button, doesn't do swipe to back: UIKIT - swift

Hey Guys I am trying to use NavigationController for back button and swipe left to back action.
can you tell me what I am doing wrong ?
Could u tell me what else to do ?
P.S. Show instead of present doesn't work as well.
let vc = UINavigationController(rootViewController: BarcodeViewController())
vc.modalPresentationStyle = .fullScreen
present(vc, animated: false)

I did solve this problem by embedding main ViewController in SceneDelegate and then push a new viewController via UINavigationController.pushViewController ..

Related

How to display the tabBar on the screen after the transition

I'm a beginner developing iOS apps using swift in Xcode.
[embarrassment]
I would like to know how to display tabBar on the screen after the transition by button.
If you press the button in FistViewController in the image below, you will go to nextViewController on the right side. I would like to know how to display the tabBar in nextViewController as well. (If you press the button to transition through the screen, the nextViewController will not display the tabBar.)
When you present a view controller modally, its presentation style will be "Full Screen" by default.What you need to do is change your modalPresentationStyle
guard let VC = self.storyboard?.instantiateViewController(withIdentifier: "yourVCName") else {
return
}
self.definesPresentationContext = true
VC.modalPresentationStyle = .overCurrentContext
self.present(VC, animated: true, completion: nil)

Present Pre-built FirebaseUI Authentication page

I am using the Pre-built Firebase UI authentication for my swift project. The goal is to present the authentication page when the user clicks on the "user profile" button. Otherwise, the user doesn't have to register or sign in.
I have initialized a navigationController. So my initial thought was to simply push the Auth controller to my navigationController.
self.navigationController?.pushViewController(authUI.authViewController(), animated: true)
It failed with the error that no nested navigation controller is allowed as the authViewController() will return an instance of the initial navigation view controller of AuthUI.
My second thought was to simply call Window and set the rootViewController as the authViewController. Then just use the authViewController as the new navigation controller
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
window?.rootViewController = authUI.authViewController()()
Unfortunately, it failed. Nothing showed up but a black screen.
The only way I figured is to call
self.present(authUI.authViewController(), animated: true, completion: nil)
However, the screen will be shown separately, which is not really what I want (see below)
Any thoughts/ideas/ suggestions are greatly appreciated.
I hope this can help you.
let authVC = authUI.authViewController()
authVC.modalPresentationStyle = .fullScreen
self.present(authVC, animated: true, completion: nil)
Thanks.

View on View controllers are all square shaped on Xcode 11, how?

I have tried to change it's size manually (by dragging) and still not working.
You can set its Content size to whatever you want.
On iOS 13 a "Modal" segue will show the presenting controller that way by default.
If you want the view controller to occupy the whole screen, set "Full Screen" on the "presentation" setting of any segue entering that controller.
Segue Settings
If your view presents programmatically (not via storyBoard), have this in mind:
From XCode 11 and up, when you build for iPad you have to add "modalPresentationStyle = .fullScreen" to get full screen views, not square ones. As follows:
let vc = UIViewController()
vc.modalPresentationStyle = .fullScreen
self.present(vc, animated: true, completion: nil)
If you want transparency on the new viewController, you can write ".overFullScreen", as follows:
let vc = UIViewController()
vc.modalPresentationStyle = .overFullScreen
self.present(vc, animated: true, completion: nil)

Present viewcontroller with tabbar

I created UITabBarController programmatically in AppDelegate with 4 view controllers(using .xib). When user tap some button on ViewController (VC-A) it present another VC (VC-B) and covered tabbar. So I want to VC-B has a tabbar on the button.
I tried to add VC-B as a child of tabbarcontroller. I tried to .present(vc) and .show(vc) on both: VC-A and VC-A.TabBarController
Creating controllers in AppDelegate:
let controllers = [tabViewController1,tabViewController2,tabViewController3,tabViewController4]
tabBarController.viewControllers = controllers
window?.rootViewController = tabBarController
presenting in VC-A
self.tabBarController?.present(controller, animated: false, completion: nil)
right click and drag from tabbar controller in storyboard to VC-B. that should create a tab on the bottom of your VC-A and VC-B to go back and forth without having to implement any backend code unless you want to animate
The solution is to embed every VC in navigationController and then add to TabBarController.
let vc1 = ViewController1()
let navController1 = UINavigationController(rootViewController: vc1)
navController.isNavigationBarHidden = true
let controllers = [navController1, navController2, navController3, navController4]
tabBarController.viewControllers = controllers
window?.rootViewController = tabBarController
Then call
self.navigationController?.pushViewController(controller, animated:
true)
To diplay VC with tabbar
I will press the red login button at the bottom of the picture and try to log in.
login button => "로그인"
After that, log in.
let moreVC = self.storyboard?.instantiateViewController(withIdentifier: "MoreViewController") as! MoreViewController
moreVC.definesPresentationContext = true
moreVC.modalPresentationStyle = .fullScreen
let navController = UINavigationController(rootViewController: moreVC)
self.present(navController, animated: true, completion: nil)
If the login proceeds without error, the above code will be called to display the screen when the login is completed.
If the flow proceeds as the code above, this screen appears.
The screen shown is not fullscreen, and the tabbar at the bottom is gone. The screen I want is the screen below.
How can I present a tab bar when presenting the screen?

How to prevent dismissal of UITabBarController by pushed SFSafariViewController?

I'm pushing SFSafariViewController into UITabBarController. But clicking on the Safari Done button dismisses the UITabBarController. How to prevent it?
If you are Pushing the SFSafariViewController try popViewController instead of dismiss
self.navigationController?.popViewController(animated: true)
Or you can present the SFSafariViewController instead of pushing it
safariViewController.modalTransitionStyle = .crossDissolve
safariViewController.modalPresentationStyle = .overCurrentContext
self.present(safariViewController, animated: false, completion:nil)