1
AdMobとスプライトキットに問題があります。AdMobのインタースティシャルメモリリーク?スプライトキット
毎回広告が表示されたり読み込まれたりすると、メモリ使用量が大幅に増加します。 EndGameSceneを開くと、 "showAd"が呼び出され、再生ボタンが押されると "loadAd"が表示されます。
広告はうまくいきます。
ゲームが開始されると、メモリ使用量は50MBのようなものになり、後で少なくとも70-100MBになります!
だから私が間違って何をすべきか:
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;}
ありがとう!