The ADBannerView class provides a view that displays banner advertisements to the user.


class ADBannerView : UIView


When the user taps a banner view, the view triggers an action programmed into the advertisement. For example, an advertisement might show a movie, present a modal advertisement, or launch Safari to show a webpage. Your application is notified when an action starts and stops, but does not otherwise interact with the advertisement. You receive revenue when users see new advertisements or trigger their actions.

The banner view’s delegate is called when a banner view cycles to show a new advertisement as well as when the user interacts with the banner view. For example, your delegate typically pauses your application’s activities when a user taps an advertisement and restores those activities when the user finishes interacting with the advertisement.

A banner view must always use one of the standard sizes defined in . This is to ensure that the advertisement is drawn correctly. You configure the banner view’s requiredContentSizeIdentifiers property with the set of possible sizes your view is allowed to use in your application. To change the size of the banner view, do not set the bounds directly; instead set the currentContentSizeIdentifier property to one of the size identifiers included in that set. You can retrieve the actual dimensions that a particular identifier equates to on a specific device by calling the sizeFromBannerContentSizeIdentifier: class method.

Subclassing Notes

The ADBannerView class provides a self-contained view. Your application should not subclass ADBannerView, nor should your application attempt to change the behavior of the banner view. For example, your application should never add subviews to a banner view.

Content Size Identifiers are strings are used to identify the size of an advertisement.

To resize a banner view, use sizeThatFits(_:) on the banner view, specifying the bounds of the view that contains the banner view. Resize the banner view with the returned size. The banner view will be sized to the correct width and height of the current device and orientation. The following code snippet shows a possible implementation:

ADBannerView *myBannerView = <#Get a banner view#>;
UIView *myContainingView = <#Get the containing view#>;
NSSize newBannerSize = [myBannerView sizeThatFits:myContainingView];
[myBannerView setBounds:newBannerSize];

See ADAdType.banner for a list of sizes.

See iAdSuite for a full example of this, including how to support resizing on older versions of iOS.



init?(adType: ADAdType)

Initializes a banner view with the specified ad type.

Instance Properties

var adType: ADAdType

The ad type of the banner view.

var advertisingSection: String?

Reserved for future use.

var isBannerLoaded: Bool

A Boolean value that states whether the banner view has downloaded an advertisement.

var isBannerViewActionInProgress: Bool

A Boolean value that states whether the banner is currently executing an user-triggered action.

var delegate: ADBannerViewDelegate?

The delegate of the banner view.

Instance Methods

func cancelAction()

Cancels an executing banner view action.