问题
I tried using the suggested code from RevMob to show a banner ad with a specific placement ID without success, tried this code:
RevMobAds *revmob = [RevMobAds revMobAds];
RevMobBanner *banner = [revmob bannerWithPlacementId:@"ID_FROM_REV_MOB"];
[banner showAd];
Tried even to add the following statement
if (IS_iPad) {
banner.frame = CGRectMake(0, 958, 768, 66);
} else if (IS_WIDESCREEN){
banner.frame = CGRectMake(0, 518, 320, 50);
} else {
banner.frame = CGRectMake(0, 430, 320, 50);
}
but no success, the only way I could be able to show banner ads was this:
[RevMobAds showBannerAdWithFrame:CGRectMake(0, 958, 768, 66) withDelegate:self];
But it didn't help to add the placement ID.
回答1:
I think you need to do it as the following by using the RevMobBannwerView instead:
RevMobAds *revmob = [RevMobAds revMobAds];
RevMobBannerView *revBannerView = [revmob bannerViewWithPlacementId:@"ID_FROM_REV_MOB"];
if (IS_iPad) {
revBannerView.frame = CGRectMake(0, 958, 768, 66);
} else if (IS_WIDESCREEN){
revBannerView.frame = CGRectMake(0, 518, 320, 50);
} else {
revBannerView.frame = CGRectMake(0, 430, 320, 50);
}
[revBannerView loadAd];
[self.view addSubview:revBannerView];
[self.view bringSubviewToFront:revBannerView];
回答2:
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");
}];
来源:https://stackoverflow.com/questions/13068356/how-to-initiate-revmob-banner-ad-with-exact-frame-and-placement-id