问题
I would like to ask the following questions:
1) How to hide iAD when the user clicks on the empty screen? 2) How to identify inactivity i.e. If user has an opened some application and leave the iphone and went away and application remained open?
Update:
According the apple documentation, this method is responsible for dismissing the iAD. but this method is still not working in my code. Any sample or how this method works?
- (void)cancelBannerViewAction
Explanation:
A banner view action can cover your application’s user interface. However, your application continues to run, and receives events normally. If your application receives an event that requires the user’s attention, it can programmatically cancel the action and uncover its interface by calling cancelBannerViewAction. Canceling actions frequently can cause a loss of revenue for your application.
Reference from Apple
But still I am unable to execute? This method is not working properly
回答1:
You can just do something like below code.
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
if (!self.adBannerViewIsVisible)
{
NSLog(@"\nBanner Success");
[UIView beginAnimations:@"animateAdBannerOn" context:NULL];
// assumes the banner view is offset 50 pixels so that it is not visible.
banner.frame = CGRectOffset(banner.frame,0,-94);
[UIView commitAnimations];
self.adBannerViewIsVisible = YES;
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
if (self.adBannerViewIsVisible)
{
NSLog(@"\nBanner Failed");
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
banner.frame = CGRectOffset(banner.frame, 0, 94);
[UIView commitAnimations];
self.adBannerViewIsVisible = NO;
}
}
Just specify location of iAd in your code then you can change it's position by just changing value in this line
banner.frame = CGRectOffset(banner.frame, 0, 94);`
Hope this may clear what you want.
来源:https://stackoverflow.com/questions/10909226/how-to-hide-iad