How to initiate revmob banner ad with exact frame and placement ID?

限于喜欢 提交于 2019-12-21 06:16:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!