Black screen appears on click of a button before navigation controller - ios

I have a sign in page with 2 text fields for username, password and a button. Once you click on that button, it takes you to a view controller. There is a navigation controller in between that viewcontroller and the signincontroller.
For some reason, I get this black screen. Yesterday deleting a segue or a element on the storyboard would stop it from happening but now its consistently happening.
If I kill the running app, click on the app icon to load it again then it shows the signincontroller as expected. But initially this keeps happening.
I'm not sure what to do exactly.
I also tried to "Reset content and settings" and it still did not work.
My flow is:
SigninVC push-> NavigationController -> ViewController (no connection between navigationcontroller and viewcontroller as signinviewcontroller's button "signin" performs the segue:
self.performSegue(withIdentifier: "signin_success", sender: self)
[Update] Also please note I tried removing NavigationController completely and it does not give me that black screen anymore although there is now a white screen appearing before it loads the signinviewcontroller

Just add your navigation controller before every other controller and show navigation bar where you need and remove it where you do not need it.
If you can not make it please send me your test project and I will make it for you :)

Related

How to present view controller with Tab Bar

My app starts off with a Tab Bar Controller on the first screen after logging in:
Later on the user can tap to get back to that screen, by pressing the Home button. The code for that is:
self.present(self.mealPlanViewController, animated: true, completion: nil)
The issue is that when they go back to that view controller, the Tab Bar is no longer there.
How can I present the view controller with the Tab Bar again?
You said:
"Later on the user can tap to get back to that screen, by pressing the Home button. The code for that is:"
self.present(self.mealPlanViewController, animated: true, completion: nil)
That is wrong. You are not "getting back" to anything. You are presenting self.mealPlanViewController modally. That means it is being drawn on top over everything else. If self.mealPlanViewController was previously on-screen, bad things may happen.
In order to help you sort it out, you need to explain your view controller hierarchy and the flow between screens. What is the name of your tab bar controller's class? Of the view controllers that are displayed as tabs? How are you getting from the tab bar controller to the screen that contains the home button?
I was able to figure it out - please see below:
I added #IBAction func unwindToContainerVC(segue: UIStoryboardSegue) {} to the view controller I wanted to go back to. This added an Action Segue.
I added the segue to the storyboard and gave it the identifier, "unwindToMealPlanViewController"
I added the following code to my Done button: self.performSegue(withIdentifier: "unwindToMealPlanViewController", sender: nil)
These were some very helpful resources in solving this:
How to perform Unwind segue programmatically?
https://www.hackingwithswift.com/example-code/uikit/how-to-perform-a-segue-programmatically-using-performsegue
https://www.youtube.com/watch?v=ULd2v4mHyQ4

Swift NavigationControllerBar Back Button

I am new in iOS development and in Swift. I have a question. I added in one of the ViewController NavigationController. But I have some problems with back button cause it doesn't appear on other Views. I tried with self.pushViewController() and with self.present() but it doesn't work. If I mark in NavigationController Is Initial View Controller then everything is fine but I don't want it because then app starts with this screen(where I have NavigationController).
Please help me, what I should to add or to write?
This is an image of my storyboard
And this is what I have if I run and go to another ViewController, as you can see I don't have navigation bar and back button.
You got 2 options :
1) Add a navigation controller in the root ViewController, Hide throughout except the last one. Make sure you push the last VC so Back option will be there by default
self.navigationController.pushToViewController(BarCodeViewController)
2) Use a custom View on top of last viewController add a custom button to that view. But this time present it from previous ViewController
self.present(BarCodeViewController)
when back button clicked dismiss it by adding target to the button. self.dismiss()

How to go to tabbar item from an external view controller

Im stuck with a problem me and a friend of mine are building a app in ios. see video.
please watch this video:
https://youtu.be/SHrBF6h8Nso
The problem is when we are done with the workout and we get to the finish workout screen and we click on the profile button it goes to the workoutOverview Screen. But we want it to go to the profileOverview screen.
We try to achieve this with this line of code :
self.tabBarController?.selectedIndex = 1. // this results in segue to workoutOverview instead of profileOverview, no matter what index we use
But finish workoutOverview is not part of tabbar controller or the navigation controller that we have.
the second problem
When pressing the cancel button (cross) we would like to pop to the first viewcontroller (muscleList) but without losing the tabbar!
see how our storyboard is connected in the picture:
Question:
How to go back to profile view controller in the tabbar controller?
How to show view controller with tabbar controller when click on the cancel button?
If anyone have a idea it would help us a lot.
xCode has a bug with the show segues. Change all "Show" segues to the deprecated "Push" segues and build and compile. Than change all back to "Show" again, build, compile and it works now! All viewcontrollers will be added to the stack.

Xcode 6 - Storyboard UINavigation Back Button not appearing in app

I have a NavigationController embedded within a TableViewController:
My Issue I am having is I can't get the back button to appear in my app :(
Is there a step I am missing here ?
Back button appears only after you push a ViewController over another one.
In this image you only set the RootViewController of your NavigationController so you have nowhere to go back so that's why back button does not appear.
You can still put programatically a button that does what you need.

UITabBar comes to uinavigation controller

I have a logout button in a viewcontroller that I have a tabbarmenu, when I press logout I can logout but my tabbarMenu is come to my navigation View controller,
would you please help me to fixed this problem, Thanks in advance,
I think you mean that you are in a tab bar controller, and when you log out you want to navigate to your loginViewController. This is happening, but your tab bars are still visible, and you want your tab bars to disappear as you have logged out.
The reason that the tab bars are still visible is because you are not navigating away from your tabBarController. You are navigating inside one of the tabs to a new loginController.
If my interpretation of your question is roughly correct, you will find the answer here:
How to handle UINavigationControllers and UITabBarControllers iOS 6.1
It shows how to deal with a loginscreen -> tab bar controller, with a logout button on each screen which will properly return you to your loginscreen (note - it doesn't create a new login screen, as you are doing here, it more correctly navigates you back to the original login screen).

Resources