CJPAdController 开源项目教程

CJPAdController 开源项目教程

CJPAdControllerA singleton class providing a simple way to add iAd and AdMob ads to a view controller. Choose one as the default, fall back to the other.项目地址:https://gitcode.com/gh_mirrors/cj/CJPAdController

1. 项目的目录结构及介绍

CJPAdController 项目的目录结构如下:

CJPAdController/
├── CJPAdController/
│   ├── CJPAdController.h
│   ├── CJPAdController.m
│   ├── Demo/
│   │   ├── DemoAppDelegate.h
│   │   ├── DemoAppDelegate.m
│   │   ├── DemoViewController.h
│   │   ├── DemoViewController.m
│   │   ├── Main.storyboard
│   │   └── Assets.xcassets
│   ├── GoogleMobileAdsSdk/
│   │   ├── GoogleMobileAds.framework
│   │   └── ...
│   ├── gitignore
│   ├── CHANGES.md
│   ├── CJPAdController.podspec
│   ├── LICENCE.txt
│   └── README.md
└── CJPAdController.podspec

目录结构介绍

  • CJPAdController/: 主目录,包含核心文件和示例Demo。
    • CJPAdController.hCJPAdController.m: 核心类文件,用于实现广告控制功能。
    • Demo/: 示例Demo目录,包含示例应用的源代码和资源文件。
      • DemoAppDelegate.hDemoAppDelegate.m: 示例应用的AppDelegate文件。
      • DemoViewController.hDemoViewController.m: 示例应用的ViewController文件。
      • Main.storyboard: 示例应用的Storyboard文件。
      • Assets.xcassets: 示例应用的资源文件。
    • GoogleMobileAdsSdk/: 包含Google Mobile Ads SDK的框架文件。
    • gitignore: Git忽略文件。
    • CHANGES.md: 项目变更记录文件。
    • CJPAdController.podspec: CocoaPods规格文件。
    • LICENCE.txt: 项目许可证文件。
    • README.md: 项目说明文件。

2. 项目的启动文件介绍

项目的启动文件是 DemoAppDelegate.m,位于 CJPAdController/Demo/ 目录下。

DemoAppDelegate.m 文件介绍

#import "DemoAppDelegate.h"
#import "CJPAdController.h"

@implementation DemoAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // 配置CJPAdController
    [CJPAdController sharedInstance].adNetworks = @[@(CJPAdNetworkiAd), @(CJPAdNetworkAdMob)];
    [CJPAdController sharedInstance].adPosition = CJPAdPositionBottom;
    [CJPAdController sharedInstance].initialDelay = 2.0;
    [CJPAdController sharedInstance].adMobUnitID = @"ca-app-pub-1234567890987654/1234567890";

    // 设置导航/标签栏控制器并启动广告服务
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:[[UIViewController alloc] init]];
    self.window.rootViewController = navController;
    [[CJPAdController sharedInstance] startWithContentViewController:navController];

    return YES;
}

@end

启动文件功能介绍

  • 导入 CJPAdController 类。
  • application:didFinishLaunchingWithOptions: 方法中配置 CJPAdController 实例。
  • 设置广告网络、广告位置、初始延迟和AdMob单元ID。
  • 创建并设置导航控制器,并启动广告服务。

3. 项目的配置文件介绍

项目的配置文件是 CJPAdController.podspec,位于项目根目录下。

CJPAdController.podspec 文件介绍

Pod::Spec.new do |spec|
  spec.name         = "CJPAdController"
  spec.version      = "1.7.1"
  spec.summary      = "A singleton class providing a simple way to add iAd and AdMob ads to a view controller."
  spec.description  = <<-DESC
                       CJPAdController is a singleton class allowing

CJPAdControllerA singleton class providing a simple way to add iAd and AdMob ads to a view controller. Choose one as the default, fall back to the other.项目地址:https://gitcode.com/gh_mirrors/cj/CJPAdController

  • 25
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

褚添北Dwight

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值