Search code examples
objective-cxcodeiad

How can I get iAd to fly in to prevent white box?


I am using a shared method to have iAD appear across three view controllers and using the App Delegate. The issue I am having is that when ads do not appear it is forming the white box. I know Apple will not approve the app if the white box appears. What can I code to have the ad start off screen and have it fly in when an ad is present and when an ad is not present, have it fly off.

I assume I would change this on all three views.

Here is the code for each .m

- (AppDelegate *) appdelegate {
return (AppDelegate *)[[UIApplication sharedApplication] delegate];
 }

 -(void) viewWillAppear:(BOOL)animated{
 _UIiAD = [[self appdelegate] UIiAD];
_UIiAD.delegate = self;

 [_UIiAD setFrame:CGRectMake(100,700,320,50)];
 [self.view addSubview:_UIiAD];
 }



 -(void)bannerViewDidLoadAd:(ADBannerView *)banner{


NSLog(@"ads loaded");
[UIView beginAnimations:nil context:nil];

[UIView setAnimationDuration:1];
[_UIiAD setAlpha:1];
[UIView commitAnimations];
}

-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
NSLog(@"ads not loaded");
[UIView beginAnimations:nil context:nil];

[UIView setAnimationDuration:1];
[_UIiAD setAlpha:0];
[UIView commitAnimations];
}

If it helps, ads are being place on the bottom of a landscape mode iPad


Solution

  • Answer supplies above. It now works for shared screen iad.