12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- //
- // RQUnDoProjectCell.m
- // NiuBi
- //
- // Created by 张嵘 on 2023/3/9.
- //
- #import "RQUnDoProjectCell.h"
- #import "GDTNativeExpressAd.h"
- #import "GDTNativeExpressAdView.h"
- @interface RQUnDoProjectCell () <GDTNativeExpressAdDelegete>
- @property (nonatomic, readwrite, strong) RQUnDoProjectItemViewModel *viewModel;
- @property (nonatomic, readwrite, strong) NSArray *expressAdViews;
- @property (nonatomic, readwrite, strong) GDTNativeExpressAd *nativeExpressAd;
- @end
- @implementation RQUnDoProjectCell
- + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
- static NSString *ID = @"RQUnDoProjectCell";
- [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID];
- RQUnDoProjectCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
- if (!cell) cell = [self rq_viewFromXib];
- return cell;
- }
- - (void)bindViewModel:(RQUnDoProjectItemViewModel *)viewModel {
- _viewModel = viewModel;
- }
- - (void)awakeFromNib {
- [super awakeFromNib];
- // 支持视频广告的 PlacementId 会混出视频与图片广告
- self.nativeExpressAd = [[GDTNativeExpressAd alloc] initWithPlacementId:@"4085226003670734" adSize:CGSizeMake(RQ_SCREEN_WIDTH - 32.f, (RQ_SCREEN_WIDTH - 32.f) * (3.f / 4.f))];
- self.nativeExpressAd.delegate = self;
- [self.nativeExpressAd loadAd:1];
- }
- - (void)nativeExpressAdSuccessToLoad:(GDTNativeExpressAd
- *)nativeExpressAd views:(NSArray<__kindof
- GDTNativeExpressAdView *> *)views {
- @weakify(self)
- self.expressAdViews = [NSArray arrayWithArray:views];
- if (self.expressAdViews.count) {
- [self.expressAdViews enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
- @strongify(self)
- GDTNativeExpressAdView *expressView = (GDTNativeExpressAdView *)obj;
- [self.contentView addSubview:expressView];
- expressView.controller = RQControllerHelper.currentViewController;
- if ([expressView isAdValid]) {
- [expressView render];
- }
- }];
- }
- }
- - (void)nativeExpressAdFailToLoad:(GDTNativeExpressAd *)nativeExpressAd error:(NSError *)error {
-
- }
- @end
|