I’m trying to create a nested storyboard structure to help break up a huge storyboard (SVN merge nightmare)…Anyway I have a parent storyboard/viewController in this case ‘NestedStoryTestViewContoller’ and two other storyboards/ViewControllers (StoryOne and StoryTwo respectively)
When you click a button in NestedStoryTestViewContoller launches StoryOne as a modal view. I can then dismiss it and get back to the NestedStoryTestViewController. However if I want to go from StoryOne directly to StoryTwo I run into issues. What I would like to do is something like:
-(IBAction)goToStoryTwo{
UIStoryboard *storyTwo = [UIStoryboard storyboardWithName:@"BoardTwo" bundle:nil];
UIViewController *boardTwoVC = [storyTwo instantiateInitialViewController];
boardTwoVC.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.presentingViewController presentModalViewController:boardTwoVC animated:YES];
}
but this does nothing.
I can dismiss the modal view with something like:
-(IBAction)goToMain{
[self dismissModalViewControllerAnimated:YES];
}
and I can call a new ModalView from NestedStoryTestViewController’s viewDidLoad method after dismissing the modalview but for that to work I would need to call some sort of method on NestedStoryTestViewCOntroller to set a property telling it which new modalview to load.
When I try to call such a method I get a nice big fat compiler error for what seems like no reason:
[self.presentingViewController setViewToLoad:@"StoryOne"];
triggers an error : Automatic Reference Counting Issue ‘Reciever type ‘UIViewController’ for instance message does not declare a method with selector ‘setViewToLoad”
The method is clearly defined and implemented and I have no idea why it throws this error. I get the same error when trying to set any properties on the ‘presentingViewController’ as well. If I put in a log statement like:
NSLog(@"parent class : %@",[[self presentingViewController] class] );
it logs ‘parent class: NestedStoryTestViewController’ as expected.
Any help is greatly appreciated as this is for work and hence pretty important and timely. I can provide project files if necessary.
Thanks,
Chris
Please Note: I am aware of the name change from ‘parentViewController’ to ‘presentingViewController’ and the project is 5.0 only so this is not the issue.
The reason that you get the error on the following line:
is because you are calling a method of your
NestedStoryTestViewControllerclass but the compiler thinks that it is aUIViewControllerclass.Since you know what the class is, you need to “convert” (or cast) it to the proper type so that the compiler knows that it will respond to your method, like this: