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 !
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];
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];
}
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");
}];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.