1
votes

I'm dealing with an application with two UIViewControllers. When the application launches, the LoaderViewController is triggered. On that view controller, I am setting up the application for launch and then trying to move into ViewController. The problem is that the prepareForSegue method is called correctly, but it does nothing. I'm trying to do the navigation same way as i've done before. What is it i might be missing here? I'm still very new in iOS development.

 class LoaderViewController: UIViewController {
 @IBOutlet weak var applicationLoadingIndicator: UIActivityIndicatorView!

  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
  }

  override func viewDidLoad() {
      super.viewDidLoad()


      applicationLoadingIndicator.startAnimating()
      self.performSegueWithIdentifier("ToMenuViewController", sender: self)
  }

  override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) {
      var vc: ViewController = segue.destinationViewController as ViewController
  }
}

Here is the image of the storyboard: enter image description here

EDIT - SOLUTION:

Solution was to change the performSegueWithIdentifier call into viewDidAppear() method.

1
Could you also share a screenshot of your storyboard and how you named your segues?Lucas van Dongen
Ofc! Added image for the post.samiljin

1 Answers

5
votes

You should not be segueing in viewDidLoad as that is way too soon. At the very least, you should instead segue in viewDidAppear.