Question

I am using Revmob for showing add banner using below code.

[RevMobAds startSessionWithAppID:@"My Application id"];

[RevMobAds session].testingMode = RevMobAdsTestingModeWithAds;

[[RevMobAds session] showBanner];

and it's showing test banner perfectly at the bottom.

Now my question is i want to set this banner at the top of my application.

so how can i set this banner frame ?

I have tried to use RevMobBannerView

My code is

RevMobBannerView *banner = [[RevMobBannerView alloc] initWithFrame:CGRectMake(0, 100, 320, 50)];

[banner setBackgroundColor:[UIColor yellowColor]];

[banner loadAd];

[self.window addSubview:banner];

but it's not working...it's not showing anything into screen.

any help will be apriciated...

Thanks !

Was it helpful?

Solution 2

In case tkanzakic answer didn't work, you can always use a UIView to put the banner into and add it to your view. In banner load delegate, resize your intermediate view to banner's bounds.

edit: Something like

ad = [[[RevMobAds session] bannerView] retain];
ad.delegate = self;
[ad loadAd];

- (void)revmobAdDidReceive {
  intermediateView.frame = CGRectMake(0,0, somewidth, someheight);
  ad.frame = intermediateView.bounds;
  [intermediateView addSubview:ad];
}

OTHER TIPS

From RevMob Documentation site:

RevMobBannerView *ad = [[RevMobAds session] bannerView];
ad.delegate = self;
[ad loadAd];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
  ad.frame = CGRectMake(0, 0, 768, 114);
} else {
  ad.frame = CGRectMake(0, 0, 320, 50);
}

[self.view addSubView:ad];

the RevMobAds object has a RevMobBannerView property, and this property has a frame. Accordingly to the documentation:

You can use this property to define the position of the banner in the screen. The default is a banner on the botton of the screen

EDIT:

Try this to set the frame:

RevMobAds *revMovAds = [RevMobAds startSessionWithAppID:@"My Application id"];
revMovAds.bannerView.frame = CGRect(x,y,xx,yy);
[revMovAds showBanner];

When I'm adding it(RevMob version 5.9) in my project. I do it like this:

[RevMobAds startSessionWithAppID:@"my id"];
RevMobBannerView *ad = [[RevMobAds session] bannerView]; // you must retain this object
[ad loadWithSuccessHandler:^(RevMobBannerView *banner) {
    banner.frame = CGRectMake(0, 381, 320, 50);
    [self.window.rootViewController.view addSubview:banner];
    NSLog(@"Ad loaded");
} andLoadFailHandler:^(RevMobBannerView *banner, NSError *error) {
    NSLog(@"Ad error: %@",error);
} onClickHandler:^(RevMobBannerView *banner) {
    NSLog(@"Ad clicked");
}];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top