1

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 !

Community
  • 1
  • 1
Sarafaraz Babi
  • 480
  • 6
  • 18

4 Answers4

4

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];
Diogo T
  • 2,591
  • 1
  • 29
  • 39
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];
}
Luis
  • 1,282
  • 1
  • 11
  • 25
  • @ Luis..i have tried to do as you say...but not able to add bannerview as subview of UIView..Can you post some code ? – Sarafaraz Babi Jan 21 '13 at 12:02
  • Thanks Luis, I had Soved this issue tomorrow by using same solution that you posted..yes it's working. +1 for you...and Thanks again for help. – Sarafaraz Babi Jan 22 '13 at 05:38
  • Hello Luis Can you help me in my Question http://stackoverflow.com/questions/14452416/revmob-check-banner-is-loaded-or-not-in-iphone – Sarafaraz Babi Jan 22 '13 at 06:00
1

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];
tkanzakic
  • 5,499
  • 16
  • 34
  • 41
0

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");
}];
sunkehappy
  • 8,970
  • 5
  • 44
  • 65