I have a class PopUpViewController
that access class MessageController
method handleLogout()
with sharedInstance static let
. But when the method is accessed and I try to present another view controller (loginController
), I get this warning in console:
"error view is not in the window hierarchy!"
Can someone help?
class PopUpViewController: UIViewController {
lazy var logOutButton: UIButton = {
let button = UIButton(type: .system)
button.translatesAutoresizingMaskIntoConstraints = false
button.setTitle("Logout", for: UIControlState())
button.titleLabel?.font = UIFont.boldSystemFont(ofSize: 20)
button.addTarget(self, action: #selector(logOut), for:.touchUpInside)
button.tintColor = .white
return button
}()
func logOut(){
removeAnimate()
MessageController.sharedInstance.handleLogout()
}
...
}
MessageController
class MessageController: UITableViewController{
static let sharedInstance = MessageController()
func handleLogout(){
do {
try FIRAuth.auth()?.signOut()
}catch let logoutError{
print(logoutError)
}
// to je za ime na vrhu ob prijavi nastavi se vrednost
let loginController = LoginController()
loginController.messagesController = self
GIDSignIn.sharedInstance().signOut() // google logout
self.present(loginController, animated: false, completion: nil)
}
}