...
Adding the wrapper to the item
The adContainer
adWrapper
will play the role of a wrapper inside the UITableViewCell
’s contentView
.
Code Block | ||
---|---|---|
| ||
class InfScrlViewCell: UITableViewCell { let label = UILabel() // This is the wrapper let adContaineradWrapper:UIView = { let view = UIView() // Specify the item ad tag here view.accessibilityLabel = "infiniteScroll_ad_wrapper_tag" return view }() override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) contentView.addSubview(label) // Added the wrapper to the item contentView.addSubview(adContaineradWrapper) // Setup the constraints ... } ... } |
...
Adding the wrapper to the item
The adContainer
adWrapper
will play the role of a wrapper inside the UICollectionView
’s contentView
.
Code Block | ||
---|---|---|
| ||
class DynamicHeightCollectionViewCell: UICollectionViewCell { let label = UILabel() let adContaineradWrapper: UIView = { let view = UIView() // Specify the item ad tag here view.accessibilityLabel = "infiniteScroll_ad_wrapper_tag" return view }() override init(frame: CGRect) { super.init(frame: frame) contentView.addSubview(label) // Added the wrapper to the item contentView.addSubview(adContainer(adWrapper) // Setup the constraints ... } ... } |
Show the Ads
Code Block | ||
---|---|---|
| ||
import UIKit
import R89SDK
class CollectionViewInfiniteScrollViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
var collectionView: UICollectionView!
...
override func viewDidLoad() {
super.viewDidLoad()
// Configure the collection view layout
...
let infiniteScrollConfigId = ConfigBuilder.companion.INFINITE_SCROLL_TEST_R89_CONFIG_ID
RefineryAdFactory.shared.createInfiniteScroll(
configurationID: infiniteScrollConfigId,
scrollView: self.collectionView,
scrollItemAdWrapperTag: "infiniteScroll_ad_wrapper_tag",
lifecycleCallbacks: nil)
}
...
} |
Info |
---|
Your They can be many or none depending on your requests, if you need one or more please request them to your account manager or technical account manager. |
Not a UITableView or UIControllerView
Get Infinite Scroll ID
When not using a UITableView or UIControllerView we need to create the infinite scroll manually and use the returned id to show ads in each of the items.
Code Block |
---|
let infiniteScrollConfigID = ConfigBuilder.companion.INFINITE_SCROLL_TEST_R89_CONFIG_ID
let infiniteScrollId = RefineryAdFactory.shared.createManualInfiniteScroll(
configurationID: infiniteScrollConfigID,
lifecycleCallbacks: nil) |
Info |
---|
Your They can be many or none depending on your requests, if you need one or more please request them to your account manager or technical account manager. |
Adding the wrapper to the item
Code Block | ||
---|---|---|
| ||
class ManualInfScrollViewCell: UIView {
let label = UILabel()
let adWrapper = UIView()
...
override init(frame: CGRect) {
super.init(frame: frame)
addSubview(label)
// Added the wrapper to the item
addSubview(adWrapper)
// Setup the constraints
...
}
...
} |
Show ads in the item
Then in each item, you will need to get the wrapper and then use it to request the ad as well you will also need to tell the request method what the “item position number in the scroll”
Code Block | ||
---|---|---|
| ||
let cellPosition = manualInfScrollViewCell.getPosition()
let adWrapper = manualInfScrollViewCell.adWrapper
RefineryAdFactory.shared.getInfiniteScrollAdForIndex(
infiniteScrollId: infiniteScrollId,
itemIndex: Int32(cellPosition),
itemAdWrapper: adWrapper,
childAdLifecycle: nil
) |
Note |
---|
Careful on the implementation of This needs to be implemented according to your implementation of the infinite scroll. EX: 20 items per page so first 20 items go from 0 to 19 and the first item of the second page is not 0 is 20 formula beeing -> pageItemIndex + (pageSize*currentPage) so first item position of first page is 0 + (20*0) item 0 plus 20 multiplied by the current page index, so page 1 has index 0 and first item position of the second page is 0 + (20*1) item 0 plus 20 multiplied by the current page index, so page 2 has index 1 second item first page would be 1 + (20*0) = 1 second item second page would be 1 + (20*1) = 21 and so on |
Lifecycle Events
You can subscribe to these events with the same method but passing a new object as a parameter. Details about this object can be found in the Reference.