Before You Start Make Sure:
- App and Placement set up on Publisher Portal
- SDK is installed
- SDK is initialized
- Each Ad request has "Testing" status which enables it to test integrations.
Headline Video is a video only ad format that provides an option to attach the video player to the top of the feed UI as the user scrolls through their feed. Headline Video is designed to be inserted into a UITableView. Each Headline Video is associated with an UIView. However, the video loading process is handled in a different way than the other ad units:
#import <DIOSDK/DIOHeadlineVideoContainer.h>
#import <DIOSDK/DIOHeadlineVideoView.h>
...
@property (nonatomic, strong) DIOHeadlineVideoContainer *container;
@property (nonatomic, strong) DIOAd *ad;
DIOPlacement *placement = [[DIOController sharedInstance]
placementWithId:@"<YOU_PLACEMENT_ID>"];
DIOAdRequest *request = [placement newAdRequest];
self.container = [[DIOHeadlineVideoContainer alloc] init];
[self.container loadWithAdRequest:request completionHandler:^(DIOAd *ad){
self.ad = ad; // Success
} errorHandler:^(NSError *error) {
// Failure
}];
The main difference is that you don’t have to wait to receive a DIOAd object in order to access the Headline Video UIView. In order to do so use:
DIOHeadlineVideoView *view = (DIOHeadlineVideoView*)
[self.container view];
Then if the view is not detached (i.e. it has not reached the top of the screen), you can add it to your UITableViewCell:
if (!view.detached) {
// Add to cell
}
When the UITableView requires the height of the row containing the Headline Video, you should return:
[(DIOHeadlineVideoView*)[self.container view] height];
By default, the frame and text in Headline Video uses black/gray for background color and white for text. It is recommended to customize this color scheme to get the best appearance within your table:
((DIOHeadlineVideoPlacement*)placement).backgroundColor = [UIColor...];
((DIOHeadlineVideoPlacement*)placement).backgroundColorSnap = [UIColor...];
((DIOHeadlineVideoPlacement*)placement).color = [UIColor...];
((DIOHeadlineVideoPlacement*)placement).colorSnap = [UIColor...];
In order to control the behavior of Headline Video in the case of a user switching between screens:
- Call [self.ad finish] to stop the ad and release the resources associated with it.
- Call [self.ad leave] to pause the video ad.
- Call [self.ad reenter] to resume the video ad.
In order to detect if Headline Video was clicked, subscribe to the <DIOAdClickDelegate> protocol and then define yourself as a delegate via:
self.ad.clickDelegate = self;
Finally implement the following to be notified whenever relevant:
- (void)onAdClicked:(DIOAd*)ad;
Check the Sample App for a fully-working example.
Comments
0 comments
Please sign in to leave a comment.