Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/150.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何在游戏中显示和隐藏广告横幅?_C++_Ios_Objective C_Iad - Fatal编程技术网

C++ 如何在游戏中显示和隐藏广告横幅?

C++ 如何在游戏中显示和隐藏广告横幅?,c++,ios,objective-c,iad,C++,Ios,Objective C,Iad,要导入横幅,我有以下内容 #import "RootViewController.h" #import "cocos2d.h" #import "platform/ios/CCEAGLView-ios.h" #import <iAd/iAd.h> @interface RootViewController() @end @implementation RootViewController 问题是在我的游戏中,整个游戏中都会出现广告,我只想在gameover.cpp初始化后出

要导入横幅,我有以下内容

#import "RootViewController.h"
#import "cocos2d.h"
#import "platform/ios/CCEAGLView-ios.h"
#import <iAd/iAd.h>

@interface RootViewController()

@end


@implementation RootViewController

问题是在我的游戏中,整个游戏中都会出现广告,我只想在gameover.cpp初始化后出现横幅。我该怎么做?GAMEOFF类是C++,RooVIEW控制器在OBJ C.< /P> < P >尝试这个代码显示和隐藏广告横幅:

- (void)showiAdBanner
 {
    if( !_adView ) { // only add to view if it's not already there
        _adView = [[ADBannerView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 50, 320, 50)]; //initialize it
        _adView.delegate = self; // set delegate
    }
    _adView.hidden = NO; //reveal it
    _bannerIsVisible = YES; //set bool to yes
}

- (void)hideiAdBanner {
   _adView.hidden = YES; //hide it
   _bannerIsVisible = NO; // set bool to no
}
无论在何处显示和隐藏,都可以调用这两个方法

- (void)showiAdBanner
 {
    if( !_adView ) { // only add to view if it's not already there
        _adView = [[ADBannerView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 50, 320, 50)]; //initialize it
        _adView.delegate = self; // set delegate
    }
    _adView.hidden = NO; //reveal it
    _bannerIsVisible = YES; //set bool to yes
}

- (void)hideiAdBanner {
   _adView.hidden = YES; //hide it
   _bannerIsVisible = NO; // set bool to no
}