how can change to other page when I change the page I got the black screen.'
I have set storyboard ID, but I don't know why it is not working.
I tried to use present or performSegue methods, but when I open the app and if user is not login then it's will transit LoginViewController. But I always get black screen.
It's a little unclear exactly which of your 2 transitions you are talking about when you say it's not working as expected, but just looking at the screenshot I can see nothing wrong with the segue you are performing to gotoLogin
. If that is broken you will need to share a lot more code to be able to solve it. I am assuming it's the else
clause that is not working:
If you are building your app in Storyboards you need to instantiate your new viewControllers from the Storyboard rather than initializing them directly. That would look like this:
if let homeVC = self.storyboard?.instantiateViewController(withIdentifier: "LoginViewController") as? LoginViewController {
// Do whatever setup you need here
self.present(homeVC, animated: true)
}
Of course you will have to make sure you have the Storyboard ID set for this to work as well.