add jpush 启动广告页
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// GiGaAdDetailViewController.h
|
||||
// GIGA
|
||||
//
|
||||
// Created by lianxiang on 2018/8/22.
|
||||
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface GiGaAdDetailViewController : UIViewController
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// GiGaAdDetailViewController.m
|
||||
// GIGA
|
||||
//
|
||||
// Created by lianxiang on 2018/8/22.
|
||||
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
||||
//
|
||||
|
||||
#import "GiGaAdDetailViewController.h"
|
||||
|
||||
@interface GiGaAdDetailViewController ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation GiGaAdDetailViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
self.title = @"广告详情";
|
||||
// Do any additional setup after loading the view.
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
/*
|
||||
#pragma mark - Navigation
|
||||
|
||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
||||
// Get the new view controller using [segue destinationViewController].
|
||||
// Pass the selected object to the new view controller.
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// GiGaStartAdView.h
|
||||
// GIGA
|
||||
//
|
||||
// Created by lianxiang on 2018/8/22.
|
||||
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
static NSString *const kAdImageNamekey = @"adImageName";
|
||||
static NSString *const kAdUrlKey = @"adUrl";
|
||||
|
||||
@interface GiGaStartAdView : UIView
|
||||
|
||||
@property (nonatomic,strong) UIImageView *adView;
|
||||
/**
|
||||
显示启动页广告
|
||||
*/
|
||||
-(void)show;
|
||||
|
||||
/**
|
||||
图片路径
|
||||
*/
|
||||
@property(nonatomic,copy) NSString *imagePath;
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,151 @@
|
||||
//
|
||||
// GiGaStartAdView.m
|
||||
// GIGA
|
||||
//
|
||||
// Created by lianxiang on 2018/8/22.
|
||||
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
||||
//
|
||||
|
||||
#import "GiGaStartAdView.h"
|
||||
#import "GiGaFileNanager.h"
|
||||
#import "UIImageView+WebCache.h"
|
||||
|
||||
@interface GiGaStartAdView()
|
||||
|
||||
@property (nonatomic,strong) UIButton *countBtn;
|
||||
@property (nonatomic,strong) NSTimer *countTimer;
|
||||
@property (nonatomic,assign) int count;
|
||||
|
||||
|
||||
@end
|
||||
static int const showTime = 12;
|
||||
|
||||
@implementation GiGaStartAdView
|
||||
|
||||
- (NSTimer *)countTimer{
|
||||
|
||||
if (!_countTimer) {
|
||||
|
||||
_countTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(countDown) userInfo:nil repeats:YES];
|
||||
|
||||
}
|
||||
return _countTimer;
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self initUIWithFrame:frame];
|
||||
}
|
||||
return self;
|
||||
|
||||
}
|
||||
-(void)initUIWithFrame:(CGRect)frame{
|
||||
|
||||
self.backgroundColor = [UIColor whiteColor];
|
||||
_adView = [[UIImageView alloc] initWithFrame:frame];
|
||||
_adView.userInteractionEnabled = YES;
|
||||
_adView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
_adView.clipsToBounds = YES;
|
||||
//广告点击手势
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoAd)];
|
||||
[_adView addGestureRecognizer:tap];
|
||||
CGFloat btnW = 60;
|
||||
CGFloat btnH = 30;
|
||||
_countBtn = [[UIButton alloc] initWithFrame:CGRectMake(KMainW - btnW - 24, btnH, btnW, btnH)];
|
||||
[_countBtn addTarget:self action:@selector(removeAdView) forControlEvents:UIControlEventTouchUpInside];
|
||||
[_countBtn setTitle:[NSString stringWithFormat:@"跳过%d",showTime] forState:UIControlStateNormal];
|
||||
_countBtn.titleLabel.font = [UIFont systemFontOfSize:15];
|
||||
[_countBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
||||
_countBtn.backgroundColor = GIGARGB(38, 38, 38, 0.6) ;
|
||||
_countBtn.layer.masksToBounds = YES;
|
||||
_countBtn.layer.cornerRadius = 4;
|
||||
[self addSubview:_adView];
|
||||
[self addSubview:_countBtn];
|
||||
|
||||
}
|
||||
|
||||
-(void)removeAdView{
|
||||
|
||||
[self.countTimer invalidate];
|
||||
self.countTimer = nil;
|
||||
[UIView animateWithDuration:0.3f animations:^{
|
||||
self.alpha = 0.f;
|
||||
} completion:^(BOOL finished) {
|
||||
[self removeFromSuperview];
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)gotoAd{
|
||||
|
||||
[self removeAdView];
|
||||
NC_POST_NAME_OBJECT(APP_PUSHTO_DETAILVIEW, nil);
|
||||
|
||||
}
|
||||
|
||||
-(void)countDown{
|
||||
|
||||
_count --;
|
||||
[_countBtn setTitle:[NSString stringWithFormat:@"跳过%d",_count] forState:UIControlStateNormal];
|
||||
if (_count == 0) {
|
||||
[self removeAdView];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-(void)show{
|
||||
|
||||
[self loadImage];
|
||||
UIWindow *window = [UIApplication sharedApplication].keyWindow;
|
||||
[window addSubview:self];
|
||||
//[self startTimer];
|
||||
//GCD 备用
|
||||
[self gcdStartCount];
|
||||
|
||||
}
|
||||
|
||||
-(void)loadImage{
|
||||
|
||||
NSArray *imageArray = @[ @"https://ss2.baidu.com/-vo3dSag_xI4khGko9WTAnF6hhy/super/whfpf%3D425%2C260%2C50/sign=a4b3d7085dee3d6d2293d48b252b5910/0e2442a7d933c89524cd5cd4d51373f0830200ea.jpg", @"https://ss0.baidu.com/-Po3dSag_xI4khGko9WTAnF6hhy/super/whfpf%3D425%2C260%2C50/sign=a41eb338dd33c895a62bcb3bb72e47c2/5fdf8db1cb134954a2192ccb524e9258d1094a1e.jpg" ];
|
||||
NSString *imageUrl = imageArray[arc4random() % imageArray.count]; // 获取图片名:43-130P5122Z60-50.jpg
|
||||
|
||||
[_adView sd_setImageWithURL:[NSURL URLWithString:imageUrl] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
|
||||
NSLog(@"%@",error);
|
||||
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(void)startTimer{
|
||||
_count = showTime;
|
||||
[[NSRunLoop mainRunLoop] addTimer:self.countTimer forMode:NSRunLoopCommonModes];
|
||||
|
||||
}
|
||||
-(void)gcdStartCount{
|
||||
|
||||
weakify(self);
|
||||
__block int timeout = showTime + 1; //倒计时时间 + 1
|
||||
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_source_t _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,queue); dispatch_source_set_timer(_timer,dispatch_walltime(NULL, 0),1.0 * NSEC_PER_SEC, 0);
|
||||
//每秒执行
|
||||
dispatch_source_set_event_handler(_timer, ^{ if(timeout <= 0){ //倒计时结束,关闭
|
||||
dispatch_source_cancel(_timer);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
[weakSelf removeAdView];
|
||||
|
||||
});
|
||||
|
||||
}else{ dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
[weakSelf.countBtn setTitle:[NSString stringWithFormat:@"跳过%d",timeout] forState:UIControlStateNormal];
|
||||
|
||||
});
|
||||
timeout--;
|
||||
|
||||
} });
|
||||
dispatch_resume(_timer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
@@ -10,7 +10,7 @@
|
||||
#import "UINavigationBar+Custom.h"
|
||||
#import "PassWordResetVC.h"
|
||||
#import "GiGaRegistViewController.h"
|
||||
|
||||
#import "GiGaUserDefault.h"
|
||||
@interface GiGaUserLoginVC ()
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *userImagView;
|
||||
@property (weak, nonatomic) IBOutlet UITextField *acountTextField;
|
||||
@@ -32,6 +32,8 @@
|
||||
[self setUpX];
|
||||
[self textFieldUI];
|
||||
[self.registBtn addTarget:self action:@selector(registBtnAction) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.loginBtn addTarget:self action:@selector(loginBtnAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -98,6 +100,7 @@
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - 去注册
|
||||
-(void)registBtnAction{
|
||||
|
||||
GiGaRegistViewController *registVC = [[GiGaRegistViewController alloc] init];
|
||||
@@ -106,5 +109,10 @@
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - 登录
|
||||
-(void)loginBtnAction:(UIButton *)btn{
|
||||
[GiGaUserDefault saveUserId:@"123"];
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
#import "UserGuardViewController.h"
|
||||
#import "GiGaUserDefault.h"
|
||||
#import "GiGaAppGaurdVC.h"
|
||||
#import "UIView+Toast.h"
|
||||
#import "GiGaMeViewController.h"
|
||||
#import "GiGaAdDetailViewController.h"
|
||||
|
||||
@interface GiGaMaskTaskViewController ()
|
||||
@property(nonatomic,strong)MaskViewBootomWaringView *waringView;
|
||||
@@ -24,7 +27,6 @@
|
||||
// Do any additional setup after loading the view.
|
||||
[self setUpNav];
|
||||
[self addNotify];
|
||||
|
||||
BOOL canshowGaurd = [GiGaUserDefault isShowedGaurd];
|
||||
if (!canshowGaurd) {
|
||||
NSLog(@"%d",(int)canshowGaurd );
|
||||
@@ -46,8 +48,16 @@
|
||||
|
||||
NC_ADD_TARGET_NAME_OBJECT(self, @selector(guardViewDissmiss), USER_GUARD_DISSMISS, nil) ;
|
||||
NC_ADD_TARGET_NAME_OBJECT(self, @selector(appGauardViewDissmiss),APP_GUARD_DISSMISS, nil) ;
|
||||
NC_ADD_TARGET_NAME_OBJECT(self, @selector(pushToAppAdDetailView),APP_PUSHTO_DETAILVIEW, nil) ;
|
||||
}
|
||||
|
||||
#pragma mark 广告详情
|
||||
-(void)pushToAppAdDetailView{
|
||||
|
||||
GiGaAdDetailViewController *detailVC=[[GiGaAdDetailViewController alloc] init];
|
||||
[self.navigationController pushViewController:detailVC animated:YES];
|
||||
|
||||
}
|
||||
#pragma mark 新手引导消失
|
||||
-(void)guardViewDissmiss{
|
||||
[self showWaringView];
|
||||
@@ -65,6 +75,8 @@
|
||||
|
||||
NC_REMOVE_NAME(self, USER_GUARD_DISSMISS, nil);
|
||||
NC_REMOVE_NAME(self, APP_GUARD_DISSMISS, nil);
|
||||
NC_REMOVE_NAME(self, APP_PUSHTO_DETAILVIEW, nil);
|
||||
|
||||
}
|
||||
|
||||
#pragma mark 新手引导
|
||||
@@ -106,11 +118,16 @@
|
||||
#pragma mark 消息 action
|
||||
|
||||
-(void)leftBtnAction{
|
||||
|
||||
GiGaUserLoginVC *userlogInVC= [[GiGaUserLoginVC alloc] init];
|
||||
GiGaBaseNavViewController *baseNav = [[GiGaBaseNavViewController alloc] initWithRootViewController:userlogInVC];
|
||||
[self presentViewController:baseNav animated:YES completion:nil];
|
||||
|
||||
BOOL isUserLogin = [GiGaUserDefault isUserLogin];
|
||||
if (isUserLogin) {
|
||||
GIGA_ShowToast(@"userLogin!");
|
||||
|
||||
|
||||
}else{
|
||||
GiGaUserLoginVC *userlogInVC= [[GiGaUserLoginVC alloc] init];
|
||||
GiGaBaseNavViewController *baseNav = [[GiGaBaseNavViewController alloc] initWithRootViewController:userlogInVC];
|
||||
[self presentViewController:baseNav animated:YES completion:nil];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark 个人中心 action
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "GiGaBlockButton.h"
|
||||
@interface MaskViewBootomWaringView : UIView
|
||||
|
||||
@property(nonatomic,strong) GiGaBlockButton *dismissBtn;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// GiGaMeViewController.h
|
||||
// GIGA
|
||||
//
|
||||
// Created by lianxiang on 2018/8/22.
|
||||
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface GiGaMeViewController : UIViewController
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// GiGaMeViewController.m
|
||||
// GIGA
|
||||
//
|
||||
// Created by lianxiang on 2018/8/22.
|
||||
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
||||
//
|
||||
|
||||
#import "GiGaMeViewController.h"
|
||||
|
||||
@interface GiGaMeViewController ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation GiGaMeViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
/*
|
||||
#pragma mark - Navigation
|
||||
|
||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
||||
// Get the new view controller using [segue destinationViewController].
|
||||
// Pass the selected object to the new view controller.
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user