Скриване на iAd банер SKScene

Здравейте момчета, какво мислите, трябва ли да използвам в известията за управление (hideAd,showAd), за да покажа и скрия моя iAd банер в моя проект, а ето какво използвам, за да покажа iAd банер `#import GameViewController.h

импортирайте GameScene.h

@interface GameViewController(){

bool adOnTop;
bool iadsBannerIsVisible;
 ADBannerView* theBanner;

}

@край

@implementation GameViewController

- (void)viewDidLoad

{

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:@"hideAd" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:@"showAd" object:nil];


[super viewDidLoad];

// Configure the view.
SKView * skView = (SKView *)self.view;
skView.showsFPS = YES;
skView.showsNodeCount = YES;
skView.multipleTouchEnabled = YES;
/* Sprite Kit applies additional optimizations to improve rendering performance */
skView.ignoresSiblingOrder = YES;

// Create and configure the scene.
GameScene *scene = [GameScene sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFit;

// Present the scene.
[skView presentScene:scene];

[self showThinBanner];

}

-(void) showThinBanner {
iadsBannerIsVisible = YES;
theBanner = [[ADBannerView alloc] initWithFrame:CGRectZero];
[theBanner setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
theBanner.delegate = self;


[self.view addSubview:theBanner];

}

- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave {
NSLog(@"Banner view is beginning an ad action");
BOOL shouldExecuteAction = YES; // your app implements this method

if (!willLeave && shouldExecuteAction){
    // insert code here to suspend any services that might conflict with the advertisement, for example, you might pause the game with an NSNotification like this...
    [[NSNotificationCenter defaultCenter] postNotificationName:@"PauseScene" object:nil]; //optional
}
return shouldExecuteAction;

}

-(void) bannerViewActionDidFinish:(ADBannerView *)banner {
NSLog(@"banner is done being fullscreen");
//Unpause the game if you paused it previously.
[[NSNotificationCenter defaultCenter] postNotificationName:@"UnPauseScene" object:nil]; //optional

}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
    

    
    if (iadsBannerIsVisible == YES) {
        
        [UIView beginAnimations:@"animateAdBannerOff" context:NULL];
        // Assumes the banner view is placed at the bottom of the screen.
         banner.frame = CGRectOffset(banner.frame, 0, banner.frame.size.height);
        [UIView commitAnimations];
        iadsBannerIsVisible = NO;
        
        NSLog(@"banner unavailable");
    }
    }



- (void)handleNotification:(NSNotification *)notification


{ 
if ([notification.name isEqualToString:@"hideAd"])
    {
         // hide your banner;
}else if ([notification.name isEqualToString:@"showAd"]) 
    {
         // show your banner
}


}

person Amory    schedule 26.01.2015    source източник


Отговори (1)


Любим

- (void)handleNotification:(NSNotification *)notification
{
if ([notification.name isEqualToString:@"hideAd"])
{
    // hide your banner;



    [theBanner removeFromSuperview];




}else if ([notification.name isEqualToString:@"showAd"])
{
    // show your banner

    [self.view addSubview:theBanner];


}
}
person Amory    schedule 26.01.2015