I updated to Swift 5 and now whenever I open my app, the main screen appears as some sort of pop up and when you swipe down, it closes and presents a blank screen, messing up the app. Any idea on how to fix this? I don't even know where to begin to look.
Here's an image of the screen:
For the blank screen in the back, here is the code that I use to determine what screen should be on top. As mentioned before, In previous versions, the screen never appears as something that could just be dropped down.
class MainNavigationController: UINavigationController {
override func viewDidLoad() {
//Sets the background to Indexed Green.
view.backgroundColor = Colors.indexedPrimary
//Checks to see if the user is logged in.
if isLoggedIn() {
perform(#selector(showApp), with: nil, afterDelay: 0.01)
} else {
//Show the logInController if the user isn't logged in already/
//The missing piece.
perform(#selector(showLogInController), with: nil, afterDelay: 0.01)
}
}
//LoggedIn Function
fileprivate func isLoggedIn() -> Bool{
return UserDefaults.standard.isLoggedIn()
}
//Shows the app if the user is logged in.
@objc func showApp(){
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc: UITabBarController = storyboard.instantiateViewController(withIdentifier: "TabBarController") as! UITabBarController
self.present(vc, animated: true, completion: nil)
}
//Show the loginController if the user isn't logged in already.
@objc func showLogInController(){
let loginScreen: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let viewcontrol: UIViewController = loginScreen.instantiateViewController(withIdentifier: "NewUsersScreenViewController") as UIViewController
self.present(viewcontrol, animated: true, completion: nil)
}
}