iOS Developer Library

Developer

iAd Framework Reference ADInterstitialAd Class Reference

Options
Deployment Target:

On This Page
Language:

ADInterstitialAd

Inherits From


Conforms To


Import Statement


Swift

import iAd

Objective-C

@import iAd;

Availability


Available in iOS 4.3 and later

The ADInterstitialAd class provides full-screen advertisements that your iPad application can display to the user. When the user taps a full-screen advertisement, the advertisement launches a full-screen ad with rich media and interactive capabilities. Your application is notified when the advertisement is launched, but does not otherwise interact with the ad. You receive revenue when users view the advertisements or interact with the advertisements displayed by your application.

To use a full-screen ad in your application, instantiate a new ADInterstitialAd object and set its delegate; your delegate is called when the ad finishes loading its content from the iAd network. Each full-screen ad only loads a single advertisement during its lifetime; each time your application wants to display a new advertisement, it must create a new ADInterstitialAd object.

After your ad object loads its content, your application can display the ad in one of two ways. To display the content modally, your application presents by calling the ad object’s presentFromViewController: method, passing in a view controller to display the content. A modal advertisement interrupts the flow of control, requiring the user to either interact with the ad or explicitly close it before the application completes the user’s current task. Alternatively, your application can create a full-screen view and call the ad object’s presentInView: method to host the advertisement in that view. A view-based advertisement is almost always added as a subview to a UIScrollView object; this allows the advertisement to be scrolled on and off the screen alongside other pages of content provided by your application.

Regardless of how your application displays the full-screen advertisement, users interact with the advertisement by tapping on it. When a user taps the advertisement, your delegate’s interstitialAdActionShouldBegin:willLeaveApplication: is called to pause your application’s actives, after which the ad downloads the rich media experience from the iAd network and displays it to the user. After the user finishes interacting with the ad, the delegate’s interstitialAdActionDidFinish: method is called to complete the action.

After an advertisement expires, it is automatically removed from the screen. The ad object calls the delegate’s interstitialAdDidUnload: method to notify your application that the advertisement is no longer being displayed. At a minimum, your application should release the ad object, but your application may want to perform additional cleanup tasks. For example, if your application created a view to display the advertisement, it may want to remove that view from the view hierarchy or provide new content to be displayed in that view.

Subclassing Notes

The ADInterstitialAd class may not be subclassed.

  • delegate delegate Property

    The delegate of the interstitial ad object.

    Declaration

    Swift

    weak var delegate: ADInterstitialAdDelegate!

    Objective-C

    @property(nonatomic, weak) id< ADInterstitialAdDelegate > delegate

    Discussion

    Your application sets a delegate to be notified when the state of the ad object changes.

    Import Statement

    Objective-C

    @import iAd;

    Swift

    import iAd

    Availability

    Available in iOS 4.3 and later

  • loaded loaded Property

    A Boolean value that states whether the interstitial ad object has downloaded an advertisement. (read-only)

    Declaration

    Swift

    var loaded: Bool { get }

    Objective-C

    @property(nonatomic, readonly, getter=isLoaded) BOOL loaded

    Discussion

    After your application creates an ad object, it automatically downloads content from the iAd Network. The value of this property is YEStrue if the ad object has finished loading advertising content, otherwise the value of this property is NOfalse. Do not poll the value of this property to determine whether an advertisement has been loaded; instead, implement the delegate’s interstitialAdDidLoad: method.

    Import Statement

    Objective-C

    @import iAd;

    Swift

    import iAd

    Availability

    Available in iOS 4.3 and later

  • Presents a full screen advertisement modally to the user.

    Declaration

    Objective-C

    - (void)presentFromViewController:(UIViewController *)viewController

    Parameters

    viewController

    The view controller to present the ad.

    Discussion

    Your application presents a full-screen advertisement modally when it requires the user to interact with the advertisement before continuing to the next screen of content in your application. For example, a game might present a modal advertisement after the player finishes playing a match; the player must dismiss the advertisement before beginning another match. When the modal advertisement is dismissed by the user, the advertisement is removed from the screen and its contents are unloaded from memory.

    An ad object throws an exception if your application presents the ad before it finishes loading content from the iAd Network.

    Import Statement

    Objective-C

    @import iAd;

    Availability

    Available in iOS 4.3 and later

    Deprecated in iOS 7.0

  • Displays the advertisement within an application view.

    Declaration

    Swift

    func presentInView(_ containerView: UIView!) -> Bool

    Objective-C

    - (BOOL)presentInView:(UIView *)containerView

    Parameters

    containerView

    A screen sized view provided by your application to hold the ad.

    Return Value

    YEStrue if the ad was added successfully, otherwise NOfalse.

    Discussion

    Your application presents a full-screen advertisement in a view when it wants the advertisement to be displayed seamlessly alongside other content, such as in a magazine layout. Typically the view is added as a subview of a scroll view configured to display its contents on page boundaries. An advertisement presented by a view expires after a period of 5 to 15 minutes. If the advertisement was offscreen when it expired, it is immediately unloaded from memory; otherwise, the advertisement is unloaded as soon as it moves offscreen.

    An ad object throws an exception if your application presents the ad before it finishes loading content from the iAd Network.

    The view passed into this method must be part of a view hierarchy managed by a view controller and must be large enough to accomodate the advertisement’s contents. The width of the view must be exactly the width of the screen. The height of the view may be up to 113 pixels shorter than the height of the screen. If your view’s size does not meet these requirements, the method returns NOfalse to your application, and the advertisement is not added to the view. See iOS Human Interface Guidelines for more information.

    While your view is displaying an advertisement, the advertisement completely covers any other content in the view. When the ad’s contents are unloaded, the advertisement is automatically removed from your view.

    Import Statement

    Objective-C

    @import iAd;

    Swift

    import iAd

    Availability

    Available in iOS 4.3 and later

  • A Boolean value that states whether the ad is currently executing an action. (read-only)

    Declaration

    Swift

    var actionInProgress: Bool { get }

    Objective-C

    @property(nonatomic, readonly, getter=isActionInProgress) BOOL actionInProgress

    Discussion

    When the user taps on the ad, the advertisement triggers an action, displaying a media rich, interactive advertisement to the user. The value of this property is YEStrue when an advertisement controls the screen, otherwise the value of this property is NOfalse.

    Your application should avoid polling this property to determine when an action starts or stops. Instead, implement the delegate methods to detect when actions begin or end.

    Import Statement

    Objective-C

    @import iAd;

    Swift

    import iAd

    Availability

    Available in iOS 4.3 and later

  • Cancels an executing advertisement.

    Declaration

    Swift

    func cancelAction()

    Objective-C

    - (void)cancelAction

    Discussion

    An advertisement that is executing on top of your application completely covers your application’s user interface, but your application continues to run. If your application receives an event that requires the user’s attention, it can programmatically cancel the advertisement so that its normal interface is restored. The ad’s delegate is not called when your application cancels the action; your application is expected to restart any services it paused before the action began executing.

    Canceling actions removes the advertisement from being displayed; frequently canceling advertisements can affect the revenue you earn from using advertisements in your application.

    Import Statement

    Objective-C

    @import iAd;

    Swift

    import iAd

    Availability

    Available in iOS 4.3 and later