Skip to content

Commit 03ae081

Browse files
committed
v3.9.0 - 1.新增部分代理方法,部分旧的代理方法做过期处理,2.几处优化...
1 parent f204304 commit 03ae081

File tree

10 files changed

+152
-113
lines changed

10 files changed

+152
-113
lines changed

README.md

Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
### 更新记录:
3131

32+
* 2017.11.22 -- v3.9.0 -->1.新增部分代理方法,部分旧的代理方法做过期处理,2.几处优化...
3233
* 2017.11.14 -- v3.8.4 -->1.版本优化,2.bug fix...
3334
* 2017.10.18 -- v3.8.0 -->1.增加对LaunchScreen.storyboard支持,2.修复pod导入编译报错问题...
3435
* 2017.10.11 -- v3.7.1 -->1.批量缓存接口增加结果回调...
@@ -80,8 +81,8 @@
8081
XHLaunchImageAdConfiguration *imageAdconfiguration = [XHLaunchImageAdConfiguration defaultConfiguration];
8182
//广告图片URLString/或本地图片名(.jpg/.gif请带上后缀)
8283
imageAdconfiguration.imageNameOrURLString = @"image0.jpg";
83-
//广告点击打开链接
84-
imageAdconfiguration.openURLString = @"http://www.it7090.com";
84+
//广告点击打开页面参数(openModel可为NSString,模型,字典等任意类型)
85+
imageAdconfiguration.openModel = @"http://www.it7090.com";
8586
//显示图片开屏广告
8687
[XHLaunchAd imageAdWithImageAdConfiguration:imageAdconfiguration delegate:self];
8788
```
@@ -107,8 +108,8 @@
107108
imageAdconfiguration.imageOption = XHLaunchAdImageRefreshCached;
108109
//图片填充模式
109110
imageAdconfiguration.contentMode = UIViewContentModeScaleToFill;
110-
//广告点击打开链接
111-
imageAdconfiguration.openURLString = @"http://www.it7090.com";
111+
//广告点击打开页面参数(openModel可为NSString,模型,字典等任意类型)
112+
imageAdconfiguration.openModel = @"http://www.it7090.com";
112113
//广告显示完成动画
113114
imageAdconfiguration.showFinishAnimate =ShowFinishAnimateFadein;
114115
//广告显示完成动画时间
@@ -150,8 +151,8 @@
150151
XHLaunchImageAdConfiguration *imageAdconfiguration = [XHLaunchImageAdConfiguration defaultConfiguration];
151152
//广告图片URLString/或本地图片名(.jpg/.gif请带上后缀)
152153
imageAdconfiguration.imageNameOrURLString = model.content;
153-
//广告点击打开链接
154-
imageAdconfiguration.openURLString = model.openUrl;
154+
//广告点击打开页面参数(openModel可为NSString,模型,字典等任意类型)
155+
imageAdconfiguration.openModel = model.openUrl;
155156
//显示开屏广告
156157
[XHLaunchAd imageAdWithImageAdConfiguration:imageAdconfiguration delegate:self];
157158
@@ -195,8 +196,8 @@
195196
imageAdconfiguration.imageOption = XHLaunchAdImageDefault;
196197
//图片填充模式
197198
imageAdconfiguration.contentMode = UIViewContentModeScaleToFill;
198-
//广告点击打开链接
199-
imageAdconfiguration.openURLString = model.openUrl;
199+
//广告点击打开页面参数(openModel可为NSString,模型,字典等任意类型)
200+
imageAdconfiguration.openModel = model.openUrl;
200201
//广告显示完成动画
201202
imageAdconfiguration.showFinishAnimate =ShowFinishAnimateLite;
202203
//广告显示完成动画时间
@@ -229,8 +230,8 @@
229230
XHLaunchVideoAdConfiguration *videoAdconfiguration = [XHLaunchVideoAdConfiguration defaultConfiguration];
230231
//广告视频URLString/或本地视频名(请带上后缀)
231232
videoAdconfiguration.videoNameOrURLString = @"video0.mp4";
232-
//广告点击打开链接
233-
videoAdconfiguration.openURLString = @"http://www.it7090.com";
233+
//广告点击打开页面参数(openModel可为NSString,模型,字典等任意类型)
234+
videoAdconfiguration.openModel = @"http://www.it7090.com";
234235
//显示视频开屏广告
235236
[XHLaunchAd videoAdWithVideoAdConfiguration:videoAdconfiguration delegate:self];
236237
```
@@ -254,8 +255,8 @@
254255
videoAdconfiguration.scalingMode = MPMovieScalingModeAspectFill;
255256
//是否只循环播放一次
256257
videoAdconfiguration.videoCycleOnce = NO;
257-
//广告点击打开链接
258-
videoAdconfiguration.openURLString = @"http://www.it7090.com";
258+
//广告点击打开页面参数(openModel可为NSString,模型,字典等任意类型)
259+
videoAdconfiguration.openModel = @"http://www.it7090.com";
259260
//广告显示完成动画
260261
videoAdconfiguration.showFinishAnimate =ShowFinishAnimateFadein;
261262
//广告显示完成动画时间
@@ -298,8 +299,8 @@
298299
XHLaunchVideoAdConfiguration *videoAdconfiguration = [XHLaunchVideoAdConfiguration defaultConfiguration];
299300
//注意:视频广告只支持先缓存,下次显示(看效果请二次运行)
300301
videoAdconfiguration.videoNameOrURLString = model.content;
301-
//广告点击打开链接
302-
videoAdconfiguration.openURLString = model.openUrl;
302+
//广告点击打开页面参数(openModel可为NSString,模型,字典等任意类型)
303+
videoAdconfiguration.openModel = model.openUrl;
303304
[XHLaunchAd videoAdWithVideoAdConfiguration:videoAdconfiguration delegate:self];
304305
305306
} failure:^(NSError *error) {
@@ -341,8 +342,8 @@
341342
videoAdconfiguration.scalingMode = MPMovieScalingModeAspectFill;
342343
//是否只循环播放一次
343344
videoAdconfiguration.videoCycleOnce = NO;
344-
//广告点击打开链接
345-
videoAdconfiguration.openURLString = model.openUrl;
345+
//广告点击打开页面参数(openModel可为NSString,模型,字典等任意类型)
346+
videoAdconfiguration.openModel = model.openUrl;
346347
//广告显示完成动画
347348
videoAdconfiguration.showFinishAnimate =ShowFinishAnimateFadein;
348349
//广告显示完成动画时间
@@ -408,16 +409,25 @@ typedef NS_ENUM(NSInteger,SkipType) {
408409

409410
### 2.点击事件
410411
```objc
412+
411413
/**
412-
* 广告点击事件 回调
413-
*/
414-
- (void)xhLaunchAd:(XHLaunchAd *)launchAd clickAndOpenURLString:(NSString *)openURLString;
415-
{
414+
广告点击事件回调
415+
*/
416+
-(void)xhLaunchAd:(XHLaunchAd *)launchAd clickAndOpenModel:(id)openModel clickPoint:(CGPoint)clickPoint{
417+
418+
NSLog(@"广告点击事件");
419+
420+
/**
421+
openModel即配置广告数据设置的点击广告时打开页面参数
422+
*/
423+
NSString *urlString = (NSString *)openModel;
416424

417-
//跳转到广告详情页面,详见demo
418-
WebViewController *VC = [[WebViewController alloc] init];
419-
VC.URLString = openURLString;
420-
.....
425+
//此处跳转页面
426+
//WebViewController *VC = [[WebViewController alloc] init];
427+
//VC.URLString = urlString;
428+
////此处不要直接取keyWindow
429+
//UIViewController* rootVC = [[UIApplication sharedApplication].delegate window].rootViewController;
430+
//[rootVC.myNavigationController pushViewController:VC animated:YES];
421431

422432
}
423433

@@ -612,7 +622,7 @@ configuration.customSkipView = [self customSkipView];
612622
}
613623

614624
/**
615-
如果你想用SDWebImage等框架加载网络广告图片,请实现此代理
625+
如果你想用SDWebImage等框架加载网络广告图片,请实现此代理(注意:实现此方法后,图片缓存将不受XHLaunchAd管理)
616626
617627
@param launchAd XHLaunchAd
618628
@param launchAdImageView launchAdImageView
@@ -626,6 +636,18 @@ configuration.customSkipView = [self customSkipView];
626636

627637
```
628638

639+
## 常见问题
640+
#### 1.为什么设置了本地图片广告,却提示找不到图片资源?
641+
* 请将本地广告图片,直接放在工程目录,不要放在Assets里面,XHLaunchAd不是通过imageName:读取图片,而是是通过[NSBundle mainBundle] path....的方式读取本地图片的(此处涉及到内存优化)
642+
643+
#### 2.为什么我启动的时候会先进入根控制器后,再显示广告页面?
644+
* 请确认下,你在请求广告数据之前,是否有调用`[XHLaunchAd setWaitDataDuration:3];`方法设置数据等待时间
645+
646+
#### 3.为什么有时候我会卡在启动广告页面(偶现)?
647+
* 此情况多出现在网络环境差时,请检查你程序启动时,有没有掉用同步方法或同步请求,(例如:环信SDK同步登录等),
648+
* XHLaunchAd采用GCD定时器,不受主线程阻塞影响,但是GCD倒计时到后,广告移除实在主线程中进行的.
649+
650+
629651
## 依赖
630652
#### 1.本库依赖于:FLAnimatedImage
631653

XHLaunchAd.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "XHLaunchAd"
3-
s.version = "3.8.4"
3+
s.version = "3.9.0"
44
s.summary = "The screen opening advertising solutions - 开屏广告、启动广告解决方案,支持图片/视频、静态/动态、全屏/半屏广告,支持iPhone/iPad,自带图片下载、缓存功能,等等."
55
s.homepage = "https://github.com/CoderZhuXH/XHLaunchAd"
66
s.license = { :type => "MIT", :file => "LICENSE" }

XHLaunchAd/XHLaunchAd/XHLaunchAd.h

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
// Copyright © 2016年 it7090.com. All rights reserved.
77
// 代码地址:https://github.com/CoderZhuXH/XHLaunchAd
88

9-
// 版本:3.8.4
10-
// 发布:2017.11.14
9+
// 版本:3.9.0
10+
// 发布:2017.11.22
1111

1212
// 如果你在使用过程中出现bug,请及时以下面任意一种方式联系我,我会及时修复bug并帮您解决问题。
1313
// QQ交流群:537476189
@@ -29,29 +29,13 @@ NS_ASSUME_NONNULL_BEGIN
2929
@optional
3030

3131
/**
32-
* 广告点击
33-
*
34-
* @param launchAd launchAd
35-
* @param openURLString 打开页面地址
36-
*/
37-
- (void)xhLaunchAd:(XHLaunchAd *)launchAd clickAndOpenURLString:(NSString *)openURLString;
38-
39-
/**
40-
* 广告点击 - 并回调点击位置(此方法与上面方法无本质区别,只是多回调一个参数[点击位置],二者实现其一即可,注意:若两者都实现,只有此方法会被执行)
32+
广告点击
4133
42-
* @param launchAd launchAd
43-
* @param openURLString 打开页面地址
44-
* @param clickPoint 点击位置
45-
*/
46-
- (void)xhLaunchAd:(XHLaunchAd *)launchAd clickAndOpenURLString:(NSString *)openURLString clickPoint:(CGPoint)clickPoint;
47-
48-
/**
49-
* 图片本地读取/或下载完成回调
50-
*
51-
* @param launchAd XHLaunchAd
52-
* @param image 读取/下载的image
34+
@param launchAd launchAd
35+
@param openModel 打开页面参数(此参数即你配置广告数据设置的configuration.openModel)
36+
@param clickPoint 点击位置
5337
*/
54-
-(void)xhLaunchAd:(XHLaunchAd *)launchAd imageDownLoadFinish:(UIImage *)image;
38+
- (void)xhLaunchAd:(XHLaunchAd *)launchAd clickAndOpenModel:(id)openModel clickPoint:(CGPoint)clickPoint;
5539

5640
/**
5741
* 图片本地读取/或下载完成回调
@@ -104,9 +88,13 @@ NS_ASSUME_NONNULL_BEGIN
10488
*/
10589
-(void)xhLaunchAd:(XHLaunchAd *)launchAd launchAdImageView:(UIImageView *)launchAdImageView URL:(NSURL *)url;
10690

107-
#pragma mark - 过期
108-
/** 请使用xhLaunchAdShowFinish: */
109-
-(void)xhLaunchShowFinish:(XHLaunchAd *)launchAd;
91+
92+
#pragma mark - 过期-XHLaunchAdDelegate
93+
- (void)xhLaunchAd:(XHLaunchAd *)launchAd clickAndOpenURLString:(NSString *)openURLString XHLaunchAdDeprecated("请使用xhLaunchAd:clickAndOpenPageModel:clickPoint:");
94+
- (void)xhLaunchAd:(XHLaunchAd *)launchAd clickAndOpenURLString:(NSString *)openURLString clickPoint:(CGPoint)clickPoint XHLaunchAdDeprecated("请使用xhLaunchAd:clickAndOpenPageModel:clickPoint:");
95+
-(void)xhLaunchAd:(XHLaunchAd *)launchAd imageDownLoadFinish:(UIImage *)image XHLaunchAdDeprecated("请使用xhLaunchAd:imageDownLoadFinish:imageData:");
96+
-(void)xhLaunchShowFinish:(XHLaunchAd *)launchAd XHLaunchAdDeprecated("请使用xhLaunchAdShowFinish:");
97+
11098
@end
11199

112100
@interface XHLaunchAd : NSObject
@@ -283,9 +271,7 @@ NS_ASSUME_NONNULL_BEGIN
283271
+(NSString *)xhLaunchAdCachePath;
284272

285273
#pragma mark - 过期
286-
/** 请使用removeAndAnimated: */
287274
+(void)skipAction XHLaunchAdDeprecated("请使用removeAndAnimated:");
288-
/** 请使用setLaunchSourceType: */
289275
+(void)setLaunchImagesSource:(LaunchImagesSource)launchImagesSource XHLaunchAdDeprecated("请使用setLaunchSourceType:");
290276

291277
@end

XHLaunchAd/XHLaunchAd/XHLaunchAd.m

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,16 @@ @interface XHLaunchAd()
3434
@property(nonatomic,copy)dispatch_source_t skipTimer;
3535
@property (nonatomic, assign) BOOL detailPageShowing;
3636
@property(nonatomic,assign) CGPoint clickPoint;
37-
38-
3937
@end
4038

4139
@implementation XHLaunchAd
42-
40+
+(void)setLaunchSourceType:(SourceType)sourceType{
41+
_sourceType = sourceType;
42+
}
4343
+(void)setWaitDataDuration:(NSInteger )waitDataDuration{
4444
XHLaunchAd *launchAd = [XHLaunchAd shareLaunchAd];
4545
launchAd.waitDataDuration = waitDataDuration;
4646
}
47-
+(void)setLaunchSourceType:(SourceType)sourceType{
48-
_sourceType = sourceType;
49-
}
50-
5147
+(XHLaunchAd *)imageAdWithImageAdConfiguration:(XHLaunchImageAdConfiguration *)imageAdconfiguration{
5248
return [XHLaunchAd imageAdWithImageAdConfiguration:imageAdconfiguration delegate:nil];
5349
}
@@ -232,9 +228,12 @@ -(void)setupImageAdForConfiguration:(XHLaunchImageAdConfiguration *)configuratio
232228
XHWeakSelf
233229
[adImageView xh_setImageWithURL:[NSURL URLWithString:configuration.imageNameOrURLString] placeholderImage:nil GIFImageCycleOnce:configuration.GIFImageCycleOnce options:configuration.imageOption completed:^(UIImage *image,NSData *imageData,NSError *error,NSURL *url){
234230
if(!error){
231+
#pragma clang diagnostic push
232+
#pragma clang diagnostic ignored"-Wdeprecated-declarations"
235233
if ([weakSelf.delegate respondsToSelector:@selector(xhLaunchAd:imageDownLoadFinish:)]) {
236234
[weakSelf.delegate xhLaunchAd:self imageDownLoadFinish:image];
237235
}
236+
#pragma clang diagnostic pop
238237
if ([weakSelf.delegate respondsToSelector:@selector(xhLaunchAd:imageDownLoadFinish:imageData:)]) {
239238
[weakSelf.delegate xhLaunchAd:self imageDownLoadFinish:image imageData:imageData];
240239
}
@@ -264,9 +263,12 @@ -(void)setupImageAdForConfiguration:(XHLaunchImageAdConfiguration *)configuratio
264263
adImageView.animatedImage = nil;
265264
adImageView.image = [UIImage imageWithData:data];
266265
}
266+
#pragma clang diagnostic push
267+
#pragma clang diagnostic ignored"-Wdeprecated-declarations"
267268
if ([self.delegate respondsToSelector:@selector(xhLaunchAd:imageDownLoadFinish:)]) {
268269
[self.delegate xhLaunchAd:self imageDownLoadFinish:[UIImage imageWithData:data]];
269270
}
271+
#pragma clang diagnostic pop
270272
}else{
271273
XHLaunchAdLog(@"未设置广告图片");
272274
}
@@ -399,21 +401,27 @@ -(void)removeAndAnimated:(BOOL)animated{
399401
if(animated){
400402
[self removeAndAnimate];
401403
}else{
402-
[self removeAndAnimateDefault];
404+
[self remove];
403405
}
404406
}
405407

406408
-(void)clickAndPoint:(CGPoint)point{
407409
self.clickPoint = point;
408410
XHLaunchAdConfiguration * configuration = [self commonConfiguration];
411+
#pragma clang diagnostic push
412+
#pragma clang diagnostic ignored"-Wdeprecated-declarations"
413+
if ([self.delegate respondsToSelector:@selector(xhLaunchAd:clickAndOpenURLString:)] && configuration.openURLString.length) {
414+
[self.delegate xhLaunchAd:self clickAndOpenURLString:configuration.openURLString];
415+
[self removeAndAnimateDefault];
416+
}
409417
if ([self.delegate respondsToSelector:@selector(xhLaunchAd:clickAndOpenURLString:clickPoint:)] && configuration.openURLString.length) {
410418
[self.delegate xhLaunchAd:self clickAndOpenURLString:configuration.openURLString clickPoint:point];
411419
[self removeAndAnimateDefault];
412-
}else{
413-
if ([self.delegate respondsToSelector:@selector(xhLaunchAd:clickAndOpenURLString:)] && configuration.openURLString.length) {
414-
[self.delegate xhLaunchAd:self clickAndOpenURLString:configuration.openURLString];
415-
[self removeAndAnimateDefault];
416-
}
420+
}
421+
#pragma clang diagnostic pop
422+
if ([self.delegate respondsToSelector:@selector(xhLaunchAd:clickAndOpenModel:clickPoint:)] && configuration.openModel) {
423+
[self.delegate xhLaunchAd:self clickAndOpenModel:configuration.openModel clickPoint:point];
424+
[self removeAndAnimateDefault];
417425
}
418426
}
419427

@@ -561,9 +569,13 @@ -(void)remove{
561569
}];
562570
_window.hidden = YES;
563571
_window = nil;
572+
573+
#pragma clang diagnostic push
574+
#pragma clang diagnostic ignored"-Wdeprecated-declarations"
564575
if ([self.delegate respondsToSelector:@selector(xhLaunchShowFinish:)]) {
565576
[self.delegate xhLaunchShowFinish:self];
566577
}
578+
#pragma clang diagnostic pop
567579
if ([self.delegate respondsToSelector:@selector(xhLaunchAdShowFinish:)]) {
568580
[self.delegate xhLaunchAdShowFinish:self];
569581
}

XHLaunchAd/XHLaunchAd/XHLaunchAdButton.m

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111

1212
/** Progress颜色 */
1313
#define RoundProgressColor [UIColor whiteColor]
14+
/** 背景色 */
15+
#define BackgroundColor [UIColor colorWithRed:0 green:0 blue:0 alpha:0.4]
16+
/** 字体颜色 */
17+
#define FontColor [UIColor whiteColor]
1418

1519
#define SkipTitle @"跳过"
1620
/** 倒计时单位 */
@@ -72,13 +76,11 @@ - (instancetype)initWithSkipType:(SkipType)skipType{
7276
break;
7377
case SkipTypeRoundProgressTime:{
7478
[self addSubview:self.timeLab];
75-
self.timeLab.backgroundColor = [UIColor clearColor];
7679
[self.timeLab.layer addSublayer:self.roundLayer];
7780
}
7881
break;
7982
case SkipTypeRoundProgressText:{
8083
[self addSubview:self.timeLab];
81-
self.timeLab.backgroundColor = [UIColor clearColor];
8284
[self.timeLab.layer addSublayer:self.roundLayer];
8385
}
8486
break;
@@ -92,8 +94,8 @@ - (instancetype)initWithSkipType:(SkipType)skipType{
9294
-(UILabel *)timeLab{
9395
if(_timeLab == nil){
9496
_timeLab = [[UILabel alloc] initWithFrame:self.bounds];
95-
_timeLab.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.4];
96-
_timeLab.textColor = [UIColor whiteColor];
97+
_timeLab.textColor = FontColor;
98+
_timeLab.backgroundColor = BackgroundColor;
9799
_timeLab.layer.masksToBounds = YES;
98100
_timeLab.textAlignment = NSTextAlignmentCenter;
99101
_timeLab.font = [UIFont systemFontOfSize:13.5];
@@ -105,7 +107,7 @@ -(UILabel *)timeLab{
105107
-(CAShapeLayer *)roundLayer{
106108
if(_roundLayer==nil){
107109
_roundLayer = [CAShapeLayer layer];
108-
_roundLayer.fillColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.4].CGColor;
110+
_roundLayer.fillColor = BackgroundColor.CGColor;
109111
_roundLayer.strokeColor = RoundProgressColor.CGColor;
110112
_roundLayer.lineCap = kCALineCapRound;
111113
_roundLayer.lineJoin = kCALineJoinRound;

0 commit comments

Comments
 (0)