I am trying to use Burstly to serve iAds and adMob ads into my iPhone app. I followed their guide
http://docs.burstly.com/guides/ad-serving-quick-start-guide.html
Here's a snippet of what I have...
MyViewController.h
@interface MyViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, OAIAdManagerDelegate> {
OAIAdManager *adManager;
IBOutlet UIView *mainView;
}
@property (nonatomic, retain) UIView *mainView;
@end
MyViewController.m
#import "MyViewController.h"
@implementation MyViewController
@synthesize mainView;
- (void)viewDidLoad {
[super viewDidLoad];
adManager = [[OAIAdManager alloc] initWithDelegate:self];
[self.view addSubview:adManager.view];
[adManager requestRefreshAd];
}
- (UIViewController *)viewControllerForModalPresentation {
return self;
}
- (CGFloat)defaultSessionLife {
return 35.0f;
}
- (Anchor)anchor {
return Anchor_Bottom;
}
- (CGPoint)anchorPoint {
return CGPointMake(self.view.frame.size.width/2, self.view.frame.size.height);
}
- (NSString *)publisherId {
return @"ENTER YOUR PUBLISHER ID HERE";
}
- (NSString *)getZone {
return @"ENTER YOUR ZONE ID HERE";
}
- (UIViewController *)viewControllerForModalPresentation {
return self;
}
// resize mainView (pull up) when ad is displayed
- (void)adManager:(OAIAdManager*)manager didLoad:(NSString*)aNetwork {
[UIView beginAnimations:@"AdResize" context:nil];
[UIView setAnimationDuration:0.7];
CGRect mainViewNewFrame = mainView.frame;
mainViewNewFrame.size.height = 460 - adSize;
mainViewNewFrame.size.width = 320;
mainViewNewFrame.origin.x = 0;
mainViewNewFrame.origin.y = 0;
mainView.frame = mainViewNewFrame;
[UIView commitAnimations];
}
// resize MainView when ad is not available
- (void)adManager:(OAIAdManager*)manager failedToLoad:(NSString*)aNetwork {
[UIView beginAnimations:@"AdResize" context:nil];
[UIView setAnimationDuration:0.7];
CGRect mainViewNewFrame = mainView.frame;
mainViewNewFrame.size.height = 460;
mainViewNewFrame.size.width = 320;
mainViewNewFrame.origin.x = 0;
mainViewNewFrame.origin.y = 0;
mainView.frame = mainViewNewFrame;
[UIView commitAnimations];
}
I'm having issues knowning exactly when an ad is being displayed so that I can know to rearrange my view. I have a table view touching the bottom of the screen, so I need to pull it up (resize my the view) when an ad is displayed.
I tried using the OAIAdManagerDelegateProtocol "adManager:didLoad:" method, which gives mixed results. That method is always called when the admanager thinks it has an ad, but sometimes an ad is not displayed (especially the first call for an iAd). So, I'm always resizing my main view to make room for an ad when that method is called, but sometimes an ad is not there to be displayed, so I end up showing a white space the size of the ad.
I also tried using the "adManager:didLoadView:" method, but it is never called.
So, is there any other way to be notified when the adManager.view is shown on screen so I can know when to resize my view?