Ich habe ein Problem mit AdMob und Sprite Kit.AdMob-Interstitial-Speicherleck? Sprite Kit
Jedes Mal, wenn die Anzeige angezeigt oder geladen wird, erhöht sich die Speichernutzung sehr! Wenn EndGameScene geöffnet wird, wird "showAd" aufgerufen, und wenn die Wiedergabetaste gedrückt wird, "loadAd".
Anzeigen funktioniert gut.
Wenn das Spiel beginnt, Speicherverbrauch ist so etwas wie 50mb und wenige Anzeigen später ist es mindestens 70-100mb!
Also, was ich falsch gemacht:
GameViewController.m
- (void)viewDidLoad{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:@"showAd" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:@"loadAd" object:nil];
self.interstitial = [self createAndLoadInterstitial];
self.interstitial = [[GADInterstitial alloc] initWithAdUnitID:@"ca-app-pub-<id>"];
GADRequest *request = [GADRequest request];
// Requests test ads on test devices.
request.testDevices = @[@"0000000"];
[self.interstitial loadRequest:request];
//etc
}
- (void)handleNotification:(NSNotification *)notification{
if ([notification.name isEqualToString:@"showAd"]) {
if (self.interstitial.isReady) {
[ self.interstitial presentFromRootViewController:self];
}
else {
}
}
if ([notification.name isEqualToString:@"loadAd"]) {
self.interstitial = [self createAndLoadInterstitial];
}
}
- (GADInterstitial *)createAndLoadInterstitial {
GADInterstitial *interstitial =
[[GADInterstitial alloc] initWithAdUnitID:@"ca-app-pub-<id>"];
interstitial.delegate = self;
[interstitial loadRequest:[GADRequest request]];
return interstitial;}
Dank!