Автоматически, когда вы устанавливаете альфа-канал ADBannerView
равным 0, он будет отключен, и реклама не будет показываться. Итак, когда метод вызывается для запуска игры, вы также должны добавить этот код:
[myAdBanner setAlpha:0];
затем, когда пользователь возвращается в главное меню или выходит из той части, где он играет в игру, вы должны добавить этот код:
[myAdBanner setAlpha:1];
Если вы хотите сделать красивую анимацию, когда просмотр баннера отключен или включен, вы можете сделать это:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:(duration in seconds)];
[banner setAlpha:(0 to disable, 1 to enable)];
[UIView commitAnimations];
Пример использования всего этого кода с использованием анимации для постепенного появления и исчезновения баннера:
- (IBAction)startGame{
//user starts the game
[UIView beginAnimations:nil context:NULL];//initiate the animation
[UIView setAnimationDuration:1];//make an animation 1 second long
[banner setAlpha:0];//disable the ad by making it invisible
[UIView commitAnimations];//do the animation above
}
- (IBAction)endGame{
//user wins, loose, or ends the game
[UIView beginAnimations:nil context:NULL];//initiate the animation
[UIView setAnimationDuration:1];//make an animation 1 second long
[banner setAlpha:1];//enable the ad by making it visible
[UIView commitAnimations];//do the animation above
}
person
Jojodmo
schedule
22.03.2014