I am trying to use the Inneractive Ad SDK 5+ in my application and I'd like to position the ad on the bottom. In every case I've tried it will always be in the middle of the screen, centred horizontally and vertically.
Code:
self.myAdView = [[IaAdView alloc]
initWithAppId:@"MyAppID_iPhone" adType:IaAdType_Banner delegate:self];
self.myAdView.adConfig.refreshIntervalInSec = 30;
[[InneractiveAdSDK sharedInstance] loadAd:self.myAdView];
Delegate method:
- (void)InneractiveAdLoaded:(IaAd *)adView {
NSLog(@"AD LOADED METHOD CALLED");
// Here I tried many things I found online without any effect
[self.view addSubview:self.myAdView];
}
Here how i implement the property at the top of the viewcontroller.m file:
@interface ViewController () <InneractiveAdDelegate>
@property (nonatomic, retain) IaAdView* myAdView;
@end
@implementation ViewController
@synthesize myAdView = _myAdView;
I am sure it must be just a tiny thing but I can't figure it out. I found many solutions that include initWithFrame
but this is not usable in this case.
Any help would be appreciated.
Update 1:
I've tried:
- (void)InneractiveAdLoaded:(IaAd *)adView {
NSLog(@"AD LOADED METHOD CALLED");
self.myAdView.frame=CGRectMake(x,y,width,height); // With any number and random number
and
self.myAdView.frame=CGRectOffset(self.myAdView.frame, 0, yOffset); // With any number and random number
[self.view addSubview:self.myAdView];
}
Nothing helped. Ad stays absolutely centred. I am starting to think there is something wrong with the setup but besides the positioning everything is working fine. See photo below.
Update 2:
Tried the following without success. ios8 shows banner centred on screen and ios7 for some reason not at all once the line has been added.
- (void)InneractiveAdLoaded:(IaAd *)adView {
NSLog(@"AD LOADED METHOD CALLED");
self.myAdView.frame = CGRectMake(0, self.view.frame.size.height - self.myAdView.frame.size.height , self.view.frame.size.width, self.myAdView.frame.size.height);
[self.view addSubview:self.myAdView];
}
Here's a working solution: You have two options here -
ANYWAY: adView must be added to it's superView before calling 'loadAd:' SDK method.
Let me know, if you have any questions.
Update: Option 2:
#import "ViewController.h"
#import "InneractiveAdSDK.h"
@interface ViewController () <InneractiveAdDelegate>
@property (nonatomic, strong) IaAdView *adView;
@end
@implementation ViewController {}
- (void)viewDidLoad {
[super viewDidLoad];
self.adView = [[IaAdView alloc] initWithAppId:@"<Your ad unit ID>" adType:IaAdType_Banner delegate:self];
[self.view addSubview:self.adView];
[[InneractiveAdSDK sharedInstance] loadAd:self.adView];
}
- (void)positionAd {
const CGFloat x = (self.view.bounds.size.width - self.adView.frame.size.width) / 2.0f;
const CGFloat y = self.view.bounds.size.height - self.adView.frame.size.height;
self.adView.frame = CGRectMake(x, y, self.adView.frame.size.width, self.adView.frame.size.height);
}
#pragma mark - InneractiveAdDelegate
- (void)InneractiveAdLoaded:(IaAd *)adView {
[self positionAd];
}
- (void)InneractiveDefaultAdLoaded:(IaAd *)adView {
[self positionAd];
}
- (UIViewController *)viewControllerForPresentingModalView { return self; }
@end