ADBanner class provides a view that displays banner advertisements to the user.
- iOS 4.0–10.0Deprecated
- Mac Catalyst 13.0–13.0Deprecated
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
required 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
current 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
size class method.
ADBanner 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:
ADAd for a list of sizes.
See iAdSuite for a full example of this, including how to support resizing on older versions of iOS.