0

So I have 2 VC's. In Sending VC I want to send data to Receive VC. I did this by PrepareForSegue in other projects, when making an UIButton. That worked perfect. But now I have created a function, that will jump to that VC when a condition is met. The function is as follows:

let vc = self.storyboard?.instantiateViewControllerWithIdentifier("Resultsviewcontroller") as! Resultsviewcontroller
let navigationController = UINavigationController(rootViewController: vc)
self.presentViewController(navigationController, animated: false, completion: nil)

It will jump to the VC, but not with the data I have declared in my PrepareForSegue function. How can I send data with a function like PrepareForSegue?

Also, when jumped to the receiving VC, it has a white line at the top. It looks like the status bar should be there, but in both VC's, I set that to "none". How can I remove that white line?

Nahaku
  • 63
  • 7

1 Answers1

0

In your case you're not presenting the controller using a segue anymore with the call of presentViewController, what you can do is ff your segue exists in the storyboard with a segue identifier between your two controllers, you can just call it programmatically using the performSegueWithIdentifier function.

In case of not exist you can set the segue manually and launch it using the function performSegueWithIdentifier. You can benefit from this answer How do I create a segue that can be called from a button that is created programmatically?

I hope this help you.

Community
  • 1
  • 1
Victor Sigler
  • 23,243
  • 14
  • 88
  • 105
  • Nice, you helped me out. This was the answer: dispatch_async(dispatch_get_main_queue()) { [unowned self] in self.performSegueWithIdentifier("Test", sender: self) } this actually solved my other problem also!! – Nahaku Jul 05 '16 at 21:39