Max Przybylla
Max Przybylla

Reputation: 18

Open ViewController via code

I am currently working on an iOS app that communicates with an Arduino via BLE, uses with multiple ViewControllers which are all set-up via Storyboard. The Views are managed via a TabBarController. At this moment I use an additional Tab to connect/Disconnect to/from the device.

But after the App is useless without the device, I want to have the ViewController (which manages the connecting task) pop up. I've read that I should use Segues, but I don't really know how to call them correctly, and I don't want to call them in every TabViewController.

Upvotes: 0

Views: 55

Answers (1)

Alec O
Alec O

Reputation: 1707

Segues are what you should use, but I would suggest learning how storyboards work first. Ray Wenderlich will be a good resource to get you started. Segues can be used either through code or directly within a storyboard.

Your question is way to general to give a direct answer, as I'd write some 1000 words to get the basis down.

To keep it simple:

  • performSegue(withIdentifier: "segueIdentifier", sender: nil)

  • presentViewController(mainViewController, animated: true, completion: nil)

  • navigationController?.pushViewController(mainViewController, animated: true)

Upvotes: 1

Related Questions