SASBannerView

Objective-C

@interface SASBannerView : SASAdView

Swift

class SASBannerView : SASAdView

The SASBannerView class provides a view that automatically loads and displays a banner creative.

The SASBAnnerView class inherits from SASAdView, which contains its most useful methods like loadWithPlacement:. We recommend you to check the SASAdView API documentation as well.

You can listen for view or ad related events by implementing the SASBannerViewDelegate protocol. Implementing this delegate can be particulary useful to hide the banner if the ad loading fails, or in the contrary, to show the banner view instance only when an ad as been successfully loaded.

Ad banner view properties

  • The object that acts as the delegate of the banner view.

    The delegate must adopt the SASBannerViewDelegate protocol.

    Declaration

    Objective-C

    @property (nonatomic, weak, nullable) id<SASBannerViewDelegate> delegate;

    Swift

    weak var delegate: (any SASBannerViewDelegate)? { get set }
  • Starts or stops the ad’s auto refresh feature on this banner view by setting the refresh interval in seconds. The refresh interval cannot be less than SASRefreshIntervalMinimum (20 seconds).

    By default, the refresh interval is set to SASRefreshIntervalOff.

    Warning

    The refresh interval will be ignored if a bidding response is currently being displayed by the banner view.

    Declaration

    Objective-C

    @property (nonatomic) NSInteger refreshInterval;

    Swift

    var refreshInterval: Int { get set }
  • Sets informations that will be used for the parallax effect.

    In most cases, the banner view will automatically get any information needed to allow the parallax effect to work properly. However in some complex integrations, the banner might compute these informations improperly. In this case, you can provide an object with the relevant informations.

    If you set a value here, parallax will not be handled automatically by the SDK anymore. Set this value to nil to get back to automatic positioning.

    Declaration

    Objective-C

    @property (nonatomic, retain, nullable) SASParallaxInfos *parallaxInfos;

    Swift

    var parallaxInfos: SASParallaxInfos? { get set }

Creating a banner view

  • Initializes a SASBannerView instance for a given frame.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithFrame:(CGRect)frame;

    Swift

    init(frame: CGRect)

    Parameters

    frame

    A rectangle specifying the initial location and size of the ad banner view in its superview’s coordinates.

  • Initializes a SASBannerView instance for a given frame with a loader.

    The loader will be displayed during the ad loading, until an ad has been fetched or until an error happens.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithFrame:(CGRect)frame
                                   loader:(SASLoader)loaderType;

    Swift

    init(frame: CGRect, loader loaderType: SASLoader)

    Parameters

    frame

    A rectangle specifying the initial location and size of the ad banner view in its superview’s coordinates.

    loaderType

    A SASLoader constant that determines which loader the view should display while downloading the ad.

Loading ad data

  • Load a bidding ad received through the SASBiddingManager.

    Call this method after initializing your SASBannerView object to load the appropriate SASBiddingAdResponse object from the server.

    Declaration

    Objective-C

    - (void)loadBiddingAdResponse:(nonnull SASBiddingAdResponse *)biddingAdResponse;

    Swift

    func load(_ biddingAdResponse: SASBiddingAdResponse)

    Parameters

    biddingAdResponse

    The SASBiddingAdResponse that should be used

Displaying a banner at proper size

  • Returns the recommanded height to display the ad view in a given container, according to the ad aspect ratio.

    If no ad is loaded, this method will return its initialization frame height for standard UIView container and will return 0 for UITableView and UICollectionView containers.

    Declaration

    Objective-C

    - (CGFloat)optimalAdViewHeightForContainer:(nullable UIView *)container;

    Swift

    func optimalAdViewHeight(forContainer container: UIView?) -> CGFloat

    Parameters

    container

    The container in which the ad will be displayed (if nil, the current window will be used instead)

    Return Value

    The optimized height for the ad view.

  • Returns the ad aspect ratio.

    If no ad is loaded, this method will return default 320x50 ad ratio

    Declaration

    Objective-C

    - (CGFloat)ratio;

    Swift

    func ratio() -> CGFloat

    Return Value

    The ratio for the ad view.