简体   繁体   中英

Revmob banner ad position - Swift

I have the following code to initialise and load a Revmob banner ad. I try to specify the position of the ad since it loads at the bottom by default and I need it to be at the top of the screen. This code however does not seem to work and my ad does not load. I've implemented this in my GameViewController class under viewDidLoad().

    let banner = RevMobBannerView()
    banner.loadAd()
    banner.frame = CGRectMake(0,0,320,50)

    let completionBlock: () -> Void = {
        banner.showAd()
        self.view.addSubview(banner)
    }

    let errorBlock: (NSError!) -> Void = {error in
        print (error);
    }

    RevMobAds.startSessionWithAppID("56b691a64756d5655fdf097e", withSuccessHandler: completionBlock, andFailHandler: errorBlock);

I moved the .loadAd() after the frame or subview is created, maybe that helps?:

let banner = RevMobBannerView()
    banner.frame = CGRectMake(0,0,320,50)
    banner.loadAd()

    let completionBlock: () -> Void = {
        self.view.addSubview(banner)
        banner.showAd()
    }

    let errorBlock: (NSError!) -> Void = {error in
        print (error);
    }

    RevMobAds.startSessionWithAppID("56b691a64756d5655fdf097e", withSuccessHandler: completionBlock, andFailHandler: errorBlock);

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM