1

Based on Xcode 7.2,Swift 2.

  1. Create a SampleVC.swift in project. (Class SampleVC : UIViewController)
  2. Create a View Controller in Storyboard.(Identity:"newView") In Interface Builder, within Identity Inspector, choose label class with SampleVC. Now I can modify "newView" within Class SampleVC.
  3. Refer "newView" with UIStoryBoard.instantiateViewControllerWithIdentifier() in code.Then presentViewController() show "newView".

I put step 3 in a button function, "newView" shows, everything is ok, but how can I pass some values to SampleVC? Am I forced to use segue here? Because I think there must be a simple solution here.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
outcast
  • 548
  • 1
  • 6
  • 20
  • If you are instantiating the VC then you can use its properties, methods etc however you like – Sami Kuhmonen Dec 21 '15 at 07:24
  • No,I can't. I put an empty array in SampleVC, can't get this property outside. There is no "as SampleVC" in code, only IB knows I combined SampleVC with "newView", that's the problem. – outcast Dec 21 '15 at 07:28
  • Then put the `as SampleVC` in? – Sami Kuhmonen Dec 21 '15 at 07:33
  • Yes! I find the same solution here: http://stackoverflow.com/questions/28289173/pass-data-to-and-from-popover-in-swift. Thank you, Sami! – outcast Dec 21 '15 at 07:37

0 Answers0