Я использую 2-й игровой движок под названием Sprite kit в Xcode, и я хочу скрыть свой рекламный баннер в определенных областях, таких как игровая сцена, а затем показать его, когда игра закончится для игрока , Но у меня возникли проблемы с попыткой доступа к скрытому свойству баннера в других сценах/классах.Скрыть баннер Admob в iOS с SpriteKit
GameViewController.h
#import <UIKit/UIKit.h>
#import <SpriteKit/SpriteKit.h>
#import <GoogleMobileAds/GoogleMobileAds.h>
#import <AVFoundation/AVFoundation.h>
@interface GameViewController : UIViewController
-(void) hideBanner;
@end
GameViewController.m
@implementation GameViewController
-(void) hideBanner {
self.bannerView.hidden = YES;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Create a banner ad and add it to the view hierarchy.
self.bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];
//TEST UNIT ID
self.bannerView.adUnitID = @"ca-app-pub-3940256099942544/2934735716";
self.bannerView.rootViewController = self;
[self.view addSubview:self.bannerView];
GADRequest *request = [GADRequest request];
request.testDevices = @[ @"*log id*" ];
[self.bannerView loadRequest:request];
}
GameScene.h
@class GameViewController;
@interface GameScene : SKScene <SKPhysicsContactDelegate>
@property (strong, nonatomic) GameViewController *gameViewController;
@end
GameScene.m
//This line of code will be executed in the "performGameOver" method but it does not work and the banner is still shown?
[self.gameViewController hideBanner];