[go: nahoru, domu]

GoogleMobileAds Framework Reference

GAMBannerView

@interface GAMBannerView : GADBannerView

The view that displays Ad Manager banner ads.

To request this ad type using GADAdLoader, you need to pass GADAdLoaderAdTypeGAMBanner (see GADAdLoaderAdTypes.h) to the |adTypes| parameter in GADAdLoader’s initializer method. If you request this ad type, your delegate must conform to the GAMBannerAdLoaderDelegate protocol.

  • Required value created on the Ad Manager 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 Ad Manager ad unit ID: @“/6499/example/banner”

    Declaration

    Swift

    var adUnitID: String? { get set }

    Objective-C

    @property (nonatomic, copy, nullable) NSString *adUnitID;
  • Optional delegate that is notified when creatives send app events.

    Declaration

    Swift

    @IBOutlet weak var appEventDelegate: (any GADAppEventDelegate)? { get set }

    Objective-C

    @property (nonatomic, weak, nullable) id<GADAppEventDelegate> appEventDelegate;
  • Optional delegate that is notified when creatives cause the banner to change size.

    Declaration

    Swift

    @IBOutlet weak var adSizeDelegate: (any GADAdSizeDelegate)? { get set }

    Objective-C

    @property (nonatomic, weak, nullable) id<GADAdSizeDelegate> adSizeDelegate;
  • Optional array of NSValue encoded GADAdSize structs, specifying all valid sizes that are appropriate for this slot. Never create your own GADAdSize directly. Use one of the predefined standard ad sizes (such as GADAdSizeBanner), or create one using the GADAdSizeFromCGSize method.

    Example:

    \code NSArray *validSizes = @[ NSValueFromGADAdSize(GADAdSizeBanner), NSValueFromGADAdSize(GADAdSizeLargeBanner) ];

    bannerView.validAdSizes = validSizes; \endcode

    Declaration

    Swift

    var validAdSizes: [NSValue]? { get set }

    Objective-C

    @property (nonatomic, copy, nullable) NSArray<NSValue *> *validAdSizes;
  • Indicates that the publisher will record impressions manually when the ad becomes visible to the user.

    Declaration

    Swift

    var enableManualImpressions: Bool { get set }

    Objective-C

    @property (nonatomic) BOOL enableManualImpressions;
  • Video controller for controlling video rendered by this ad view.

    Declaration

    Swift

    var videoController: GADVideoController { get }

    Objective-C

    @property (nonatomic, readonly, nonnull) GADVideoController *videoController;
  • If you’ve set enableManualImpressions to YES, call this method when the ad is visible.

    Declaration

    Swift

    func recordImpression()

    Objective-C

    - (void)recordImpression;
  • Use this function to resize the banner view without launching a new ad request.

    Declaration

    Swift

    func resize(_ size: GADAdSize)

    Objective-C

    - (void)resize:(GADAdSize)size;
  • Sets options that configure ad loading.

    Declaration

    Swift

    func setAdOptions(_ adOptions: [GADAdLoaderOptions])

    Objective-C

    - (void)setAdOptions:(nonnull NSArray<GADAdLoaderOptions *> *)adOptions;

    Parameters

    adOptions

    An array of GADAdLoaderOptions objects. The array is deep copied and option objects cannot be modified after calling this method.