首页 > 代码库 > 控制广告时间
控制广告时间
// 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
控制广告时间
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。