Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IBOutlets to other view controllers in storyboard

I want to switch between multiple view controllers with a UIPageViewController. These view controllers are static though so i want to design them in my storyboard. Since one can't use relationships or segues to connect them to the UIPageViewController but a datasource, I need to have a datasource object with an IBOutletCollection holding the pages:

@property (retain, nonatomic) IBOutletCollection(UIViewController) NSArray* pages;

Although, I am not able to connect this outlet to the view controllers in question. I guess thats because view controllers in a story board are treated completely independently like they were in different nib files. Is there a solution though? I don't want to design these view controllers in code.

like image 585
Sebastian Hoffmann Avatar asked Jan 17 '12 16:01

Sebastian Hoffmann


1 Answers

An IBOutlet is probably not the way to go about this. The best way to do so in my opinion would be to get the nib file using an identifier that you specify in storyboard and then in the viewDidLoad method, type this in and replace the variable name and identifier with the applicable names.

UIViewController *myController = [self.storyboard instantiateViewControllerWithIdentifier:@"myIdentifier"];

Hope this helped you get it working.

like image 149
Marcus Buffett Avatar answered Sep 26 '22 19:09

Marcus Buffett