问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/8898445/iboutlets-to-other-view-controllers-in-storyboard