Modal Segue storyboard with delegate

I made an application using iOS6 without realizing that they were not in iOS5, and so I am parsing them to support iOS5. So far, I have decided that I need to use delegates to get the information back to the root view from the segue modal view and have some good examples to follow, and I'm sure I understand.

Currently, a modal segment is generated through a storyboard, but not through code.

To set a delegate as my root view, will I need to generate it using code or is there a way through storyboards?

+4
source share
1 answer

Before executing segue, the program will call the method - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender in sourceViewController (the view controller that calls segue). In this method, you can specify a destinationViewController reference to self:

 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { [segue.destinationViewController setDelegate:self]; } 

Of course, you need a property in destinationViewController:

 @property (weak, nonatomic) id<yourProtocol> delegate; 

Hope this helps.

+12
source

Source: https://habr.com/ru/post/1444971/


All Articles