Reputation: 33
I have a class that ViewController.swift linked to a UIViewController in my storyboard:
I have another class called ExpandableViewController and in it I try to resend ViewController:
var viewController:UIViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("ExpandableViewController") as UIViewController
self.presentViewController(viewController, animated: false, completion: nil)
But my viewController variable can not access the variable button in this class ViewController.swift am unable to create this subclass in ExpandableViewController.
How could I do that?
Upvotes: 0
Views: 40
Reputation: 8651
Couple of issues:
var viewController:UIViewController
should be
var viewController:ViewController
You have subclassed UIViewController as ViewController
It would also be a good idea to give ViewController a storyboard id that is not the same as your other custom class (ExpandableViewController).
You will want to do something like:
let viewController:ViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("ViewController1") as! ViewController
self.presentViewController(viewController, animated: false, completion: nil)
viewController.button.setTitle("TEST", forState: UIControlState.Normal)
Upvotes: 1