In my main view controller, an NSTimer calls the function below after a specified delay:
-(void)showAdView{
[self performSegueWithIdentifier:@"ShowAdSegue" sender:nil];
}
This modally presents MyAdViewController, and I'd like the MyAdViewController class to have a MyAdViewControllerDelegate protocol, so that I can implement an adViewDidFinish function in my main view controller.
Is it possible to do that without creating a new instance of MyAdViewController in the main view controller?
You can do the following:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
[segue.destinationViewController setDelegate:self];
}
For this to work you have to include your view controller header file in the view controller executing the segue and also make the delegate property of your MyAdViewController public by adding it to the header file of the class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With