Answer the question
In order to leave comments, you need to log in
How to open a new ViewController from its class?
Good evening. I'm learning swift and trying to write a program out of necessity. You need to make a transition to another ViewController from a custom class. But even UIViewController inheritance doesn't help.
It would seem that this example should help :
public class MyClass: UIViewController {
private func goToLogin() {
let vc = self.storyboard?.instantiateViewControllerWithIdentifier("LogIn") as! LogInViewController
self.presentViewController(vc, animated: true, completion: nil)
}
}
Answer the question
In order to leave comments, you need to log in
What is the best way to pass data between ViewControllers?
How to create transition between ViewController by condition?
UPD. If you need it not from the controller, then:
UIApplication.sharedApplication().keyWindow?.rootViewController?.presentViewController(vc, animated: true, completion: nil)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question