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
}