Stay organized with collections
Save and categorize content based on your preferences.
GADBannerView
classGADBannerView:UIView
The view that displays banner ads. A minimum implementation to get an ad from within a
UIViewController class is:
// Create and setup the ad view, specifying the size and origin at {0, 0}.
GADBannerView *adView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
adView.rootViewController = self;
adView.adUnitID = @ID created when registering your app;
// Place the ad view onto the screen.
[self.view addSubview:adView];
// Request an ad without any additional targeting information.
[adView loadRequest:[GADRequest request]];
Required value created on the AdMob website. Create a new ad unit for every unique placement of
an ad in your application. Set this to the ID assigned for this placement. Ad units are
important for targeting and statistics.
Example AdMob ad unit ID: @ca-app-pub-0123456789012345/0123456789
Required reference to a root view controller that is used by the banner to present full screen
content after the user interacts with the ad. The root view controller is most commonly the view
controller displaying the banner.
Required to set this banner view to a proper size. Never create your own GADAdSize directly.
Use one of the predefined standard ad sizes (such as kGADAdSizeBanner), or create one using the
GADAdSizeFromCGSize method. If not using mediation, then changing the adSize after an ad has
been shown will cause a new request (for an ad of the new size) to be sent. If using mediation,
then a new request may not be sent.
A Boolean value that determines whether autoloading of ads in the receiver is enabled. If
enabled, you do not need to call the loadRequest: method to load ads.
The ad network class name that fetched the current ad. Returns nil while the latest ad request
is in progress or if the latest ad request failed. For both standard and mediated Google AdMob
ads, this property returns @GADMAdapterGoogleAdMobAds. For ads fetched via mediation custom
events, this property returns @GADMAdapterCustomEvents.
Indicates whether the currently displayed ad (or most recent failure) was a result of auto
refreshing as specified on server. This property is set to NO after each loadRequest: method.
The mediated ad network’s underlying ad view. You may use this property to read the ad’s actual
size and adjust this banner view’s frame origin. However, modifying the banner view’s frame size
triggers the Mobile Ads SDK to request a new ad. Only update the banner view’s frame origin.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2021-03-03 UTC."],[],[],null,["# GoogleMobileAds Framework Reference\n\nGADBannerView\n=============\n\n class GADBannerView : UIView\n\nThe view that displays banner ads. A minimum implementation to get an ad from within a\nUIViewController class is:\n\n\u003cbr /\u003e\n\n```\n // Create and setup the ad view, specifying the size and origin at {0, 0}.\n GADBannerView *adView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];\n adView.rootViewController = self;\n adView.adUnitID = @ID created when registering your app;\n // Place the ad view onto the screen.\n [self.view addSubview:adView];\n // Request an ad without any additional targeting information.\n [adView loadRequest:[GADRequest request]];\n \n```\n\n\u003cbr /\u003e\n\n[Initialization\n--------------](#/Initialization)\n\n- `\n ``\n ``\n `\n\n ### [init(adSize:origin:)](#/c:objc(cs)GADBannerView(im)initWithAdSize:origin:)\n\n `\n ` \n Initializes and returns a banner view with the specified ad size and origin relative to the\n banner's superview. \n\n #### Declaration\n\n Swift \n\n init(adSize: ../Structs/GADAdSize.html, origin: CGPoint)\n\n- `\n ``\n ``\n `\n\n ### [init(adSize:)](#/c:objc(cs)GADBannerView(im)initWithAdSize:)\n\n `\n ` \n Initializes and returns a banner view with the specified ad size placed at its superview's\n origin. \n\n #### Declaration\n\n Swift \n\n init(adSize: ../Structs/GADAdSize.html)\n\n[Pre-Request\n-----------](#/Pre-Request)\n\n- `\n ``\n ``\n `\n\n ### [adUnitID](#/c:objc(cs)GADBannerView(py)adUnitID)\n\n `\n ` \n Required value created on the AdMob website. Create a new ad unit for every unique placement of\n an ad in your application. Set this to the ID assigned for this placement. Ad units are\n important for targeting and statistics.\n\n Example AdMob ad unit ID: @ca-app-pub-0123456789012345/0123456789 \n\n #### Declaration\n\n Swift \n\n var adUnitID: String? { get set }\n\n- `\n ``\n ``\n `\n\n ### [rootViewController](#/c:objc(cs)GADBannerView(py)rootViewController)\n\n `\n ` \n Required reference to a root view controller that is used by the banner to present full screen\n content after the user interacts with the ad. The root view controller is most commonly the view\n controller displaying the banner. \n\n #### Declaration\n\n Swift \n\n @IBOutlet weak var rootViewController: UIViewController? { get set }\n\n- `\n ``\n ``\n `\n\n ### [adSize](#/c:objc(cs)GADBannerView(py)adSize)\n\n `\n ` \n Required to set this banner view to a proper size. Never create your own GADAdSize directly.\n Use one of the predefined standard ad sizes (such as kGADAdSizeBanner), or create one using the\n GADAdSizeFromCGSize method. If not using mediation, then changing the adSize after an ad has\n been shown will cause a new request (for an ad of the new size) to be sent. If using mediation,\n then a new request may not be sent. \n\n #### Declaration\n\n Swift \n\n var adSize: ../Structs/GADAdSize.html { get set }\n\n- `\n ``\n ``\n `\n\n ### [delegate](#/c:objc(cs)GADBannerView(py)delegate)\n\n `\n ` \n Optional delegate object that receives state change notifications from this GADBannerView.\n Typically this is a UIViewController. \n\n #### Declaration\n\n Swift \n\n @IBOutlet weak var delegate: ../Protocols/GADBannerViewDelegate.html? { get set }\n\n- `\n ``\n ``\n `\n\n ### [adSizeDelegate](#/c:objc(cs)GADBannerView(py)adSizeDelegate)\n\n `\n ` \n Optional delegate that is notified when creatives cause the banner to change size. \n\n #### Declaration\n\n Swift \n\n @IBOutlet weak var adSizeDelegate: ../Protocols/GADAdSizeDelegate.html? { get set }\n\n[Making an Ad Request\n--------------------](#/Making%20an%20Ad%20Request)\n\n- `\n ``\n ``\n `\n\n ### [load(_:)](#/c:objc(cs)GADBannerView(im)loadRequest:)\n\n `\n ` \n Requests an ad. The request object supplies targeting information. \n\n #### Declaration\n\n Swift \n\n func load(_ request: ../Classes/GADRequest.html?)\n\n- `\n ``\n ``\n `\n\n ### [isAutoloadEnabled](#/c:objc(cs)GADBannerView(py)autoloadEnabled)\n\n `\n ` \n A Boolean value that determines whether autoloading of ads in the receiver is enabled. If\n enabled, you do not need to call the loadRequest: method to load ads. \n\n #### Declaration\n\n Swift \n\n var isAutoloadEnabled: Bool { get set }\n\n[Mediation\n---------](#/Mediation)\n\n- `\n ``\n ``\n `\n\n ### [adNetworkClassName](#/c:objc(cs)GADBannerView(py)adNetworkClassName)\n\n `\n ` \n The ad network class name that fetched the current ad. Returns nil while the latest ad request\n is in progress or if the latest ad request failed. For both standard and mediated Google AdMob\n ads, this property returns @GADMAdapterGoogleAdMobAds. For ads fetched via mediation custom\n events, this property returns @GADMAdapterCustomEvents. \n\n #### Declaration\n\n Swift \n\n var adNetworkClassName: String? { get }\n\n[Deprecated\n----------](#/Deprecated)\n\n- `\n ``\n ``\n `\n\n ### [hasAutoRefreshed](#/c:objc(cs)GADBannerView(py)hasAutoRefreshed)\n\n `\n ` \n Indicates whether the currently displayed ad (or most recent failure) was a result of auto\n refreshing as specified on server. This property is set to NO after each loadRequest: method. \n\n #### Declaration\n\n Swift \n\n var hasAutoRefreshed: Bool { get }\n\n- `\n ``\n ``\n `\n\n ### [inAppPurchaseDelegate](#/c:objc(cs)GADBannerView(py)inAppPurchaseDelegate)\n\n `\n ` \n Deprecated delegate. GADInAppPurchase is deprecated. \n\n #### Declaration\n\n Swift \n\n @IBOutlet weak var inAppPurchaseDelegate: ../Protocols/GADInAppPurchaseDelegate.html? { get set }\n\n- `\n ``\n ``\n `\n\n ### [mediatedAdView](#/c:objc(cs)GADBannerView(py)mediatedAdView)\n\n `\n ` \n The mediated ad network's underlying ad view. You may use this property to read the ad's actual\n size and adjust this banner view's frame origin. However, modifying the banner view's frame size\n triggers the Mobile Ads SDK to request a new ad. Only update the banner view's frame origin. \n\n #### Declaration\n\n Swift \n\n weak var mediatedAdView: UIView? { get }"]]