iOS Creating a wrapper
The wrapper is an empty UIView
that can be created and linked from the XCode’s UI builder or be programmatically in the view controller.
Link in the XCode’s UI builder.
Here is a short example that demonstrates the wrapper usage by creating it in the XCode’s UI Builder.
The adWrapper
is linked with the AdViewController
, and provided to the RefineryAdFactory.shared.createBanner(:wrapper,...)
method.
class AdViewController: UIViewController {
@IBOutlet var adWrapper:UIView!
override func viewDidLoad() {
super.viewDidLoad()
...
// Passing the adWrapper wrapper to the SDK, so it can display a banner ad in it.
RefineryAdFactory.shared.createBanner(
wrapper: adWrapper,
configurationID: ConfigBuilder.companion.BANNER_TEST_R89_CONFIG_ID,
lifecycleCallbacks: nil)
}
}
Now the ad will be placed inside the adContainer
.
Create programmatically in the UIViewController
Here is the equivalent example to create a wrapper programmatically and display an ad in it.
class AdViewController: UIViewController {
let adWrapper = UIView()
override func viewDidLoad() {
super.viewDidLoad()
// Add and center the adWrapper in it's parent
view.addSubview(adContainer)
...
// Passing the adWrapper wrapper to the SDK, so it can display a banner ad in it.
RefineryAdFactory.shared.createBanner(
wrapper: adWrapper,
configurationID: ConfigBuilder.companion.BANNER_TEST_R89_CONFIG_ID,
lifecycleCallbacks: nil)
}
}
Now the adWrapper
has been created programmatically. It is added and centered in its parent. In the next step, the instance of adWrapper
is provided to the RefineryAdFactory.shared.createBanner(:wrapper,...)
, so the SDK will display the ad in it.