首页 > 代码库 > 控制广告时间

控制广告时间

//  XMGAdViewController.m#import "XMGAdViewController.h"#import <AFNetworking/AFNetworking.h>#import "XMGADItem.h"#import <MJExtension/MJExtension.h>#import <UIImageView+WebCache.h>#import "XMGTabBarController.h"@interface XMGAdViewController ()@property (weak, nonatomic) IBOutlet UIImageView *launchImageView;@property (weak, nonatomic) IBOutlet UIView *adContainView;@property (nonatomic, weak) UIImageView *adView;@property (nonatomic, strong) XMGADItem *item;@property (nonatomic, weak) NSTimer *timer;@property (weak, nonatomic) IBOutlet UIButton *jumpBtn;@end@implementation XMGAdViewController// 点击跳转做的事情- (IBAction)clickJump:(id)sender {    // 销毁广告界面,进入主框架界面    XMGTabBarController *tabBarVc = [[XMGTabBarController alloc] init];    [UIApplication sharedApplication].keyWindow.rootViewController = tabBarVc;        // 干掉定时器    [_timer invalidate];}- (void)viewDidLoad {    [super viewDidLoad];    // Do any additional setup after loading the view.    // 设置启动图片    [self setupLaunchImage];        // 加载广告数据 => 拿到活时间 => 服务器 => 查看接口文档 1.判断接口对不对 2.解析数据(w_picurl,ori_curl:跳转到广告界面,w,h) => 请求数据(AFN)    [self loadAdData];        // 创建定时器    _timer =  [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timeChange) userInfo:nil repeats:YES];}- (void)timeChange{    // 倒计时    static int i = 3;        if (i == 0) {            [self clickJump:nil];            }        i--;        // 设置跳转按钮文字    [_jumpBtn setTitle:[NSString stringWithFormat:@"跳转 (%d)",i] forState:UIControlStateNormal];}@end

 

控制广告时间