The most clean solution is to declare and implement a protocol to let the UIViewController
know that it should hide the ad.
@protocol MySceneDelegate <NSObject>
- (void)hideAd;
- (void)showAd;
@end
@interface MyScene : SKScene
@property (weak) id <MySceneDelegate> delegate;
@end
View controller that shows the scene should implement a hideAd
method and set itself as a delegate of the scene. Example:
- (void)viewDidLoad
{
[super viewDidLoad];
// Configure the view, etc.
...
// Set the delegate
[scene setDelegate:self];
// Present the scene.
[skView presentScene:scene];
}
Then in the scene you don't want to show an ad, you can call the hideAd
method of the view controller which was set as a delegate:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
/* Called when a touch begins */
if ([_delegate respondsToSelector:@selector(hideAd)])
{
[_delegate performSelector:@selector(hideAd)];
}
}
You can tell the view controller to show the ad in the same way. Hope it helps.