D
D
Dmitry Chizhov2016-03-03 21:59:45
iOS
Dmitry Chizhov, 2016-03-03 21:59:45

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)
    }
}

I couldn’t google it, at least because I have no idea what this redirect is called. I googled for a long time, but I didn't find anything similar =)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
ManWithBear, 2016-03-03
@ManWithBear

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 question

Ask a Question

731 491 924 answers to any question