123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- //
- // RQUnDoProjectTableViewCell.m
- // NiuBi
- //
- // Created by 张嵘 on 2023/3/14.
- //
- #import "RQUnDoProjectTableViewCell.h"
- #import "GDTNativeExpressAd.h"
- #import "GDTNativeExpressAdView.h"
- @interface RQUnDoProjectTableViewCell () <GDTNativeExpressAdDelegete>
- @property (nonatomic, readwrite, strong) RQUnDoProjectTableViewItemViewModel *viewModel;
- @property (nonatomic, readwrite, strong) NSArray *expressAdViews;
- @property (weak, nonatomic) IBOutlet UIView *myAdView;
- @property (nonatomic, readwrite, strong) GDTNativeExpressAd *nativeExpressAd;
- @end
- @implementation RQUnDoProjectTableViewCell
- + (instancetype)cellWithTableView:(UITableView *)tableView {
- static NSString *ID = @"RQUnDoProjectTableViewCell";
- RQUnDoProjectTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
- if (!cell) {
- cell = [self rq_viewFromXib];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- }
- return cell;
- }
- - (void)bindViewModel:(RQUnDoProjectTableViewItemViewModel *)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)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- - (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.myAdView addSubview:expressView];
- expressView.controller = RQControllerHelper.currentViewController;
- if ([expressView isAdValid]) {
- [expressView render];
- }
- }];
- }
- }
- - (void)nativeExpressAdFailToLoad:(GDTNativeExpressAd *)nativeExpressAd error:(NSError *)error {
-
- }
- @end
|