I've been debating with this for a while now, hope you can help me.
I've been creating an app using storyboards mostly, I have a point where I popup a modal box to add a new record, popup works fine, the problem is dismissing it.
I've followed Apple's instructions on how to properly close modal boxes using delegates, and that works fine, except I need to add a navigation controller to my modal box, because the add process requires two steps (here fullscreen):
The problem lies in setting the delegate, so here are my two questions:
1- In my root view class (My Tab) is a delegate of the Add class (the modal), everything is set up right except this:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showAdd"]) {
[[segue destinationViewController] setDelegate:self];
}
}
The problem lies in that [segue destinationViewController] is returning the navigationcontroller and not the AddDrinkViewController class (see the storyboard). How do I get around this? If I remove the navigation controller altogether, the code works fine setting the appropriate delegate.
2- Is there any way to set the delegate by dragging the outlets in the storyboard?
Thanks!
See Question&Answers more detail:os