Skip to content

Commit

Permalink
v3.9.0 - 1.新增部分代理方法,部分旧的代理方法做过期处理,2.几处优化...
Browse files Browse the repository at this point in the history
  • Loading branch information
CoderZhuXH committed Nov 22, 2017
1 parent f204304 commit 03ae081
Show file tree
Hide file tree
Showing 10 changed files with 152 additions and 113 deletions.
72 changes: 47 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

### 更新记录:

* 2017.11.22 -- v3.9.0 -->1.新增部分代理方法,部分旧的代理方法做过期处理,2.几处优化...
* 2017.11.14 -- v3.8.4 -->1.版本优化,2.bug fix...
* 2017.10.18 -- v3.8.0 -->1.增加对LaunchScreen.storyboard支持,2.修复pod导入编译报错问题...
* 2017.10.11 -- v3.7.1 -->1.批量缓存接口增加结果回调...
Expand Down Expand Up @@ -80,8 +81,8 @@
XHLaunchImageAdConfiguration *imageAdconfiguration = [XHLaunchImageAdConfiguration defaultConfiguration];
//广告图片URLString/或本地图片名(.jpg/.gif请带上后缀)
imageAdconfiguration.imageNameOrURLString = @"image0.jpg";
//广告点击打开链接
imageAdconfiguration.openURLString = @"http://www.it7090.com";
//广告点击打开页面参数(openModel可为NSString,模型,字典等任意类型)
imageAdconfiguration.openModel = @"http://www.it7090.com";
//显示图片开屏广告
[XHLaunchAd imageAdWithImageAdConfiguration:imageAdconfiguration delegate:self];
```
Expand All @@ -107,8 +108,8 @@
imageAdconfiguration.imageOption = XHLaunchAdImageRefreshCached;
//图片填充模式
imageAdconfiguration.contentMode = UIViewContentModeScaleToFill;
//广告点击打开链接
imageAdconfiguration.openURLString = @"http://www.it7090.com";
//广告点击打开页面参数(openModel可为NSString,模型,字典等任意类型)
imageAdconfiguration.openModel = @"http://www.it7090.com";
//广告显示完成动画
imageAdconfiguration.showFinishAnimate =ShowFinishAnimateFadein;
//广告显示完成动画时间
Expand Down Expand Up @@ -150,8 +151,8 @@
XHLaunchImageAdConfiguration *imageAdconfiguration = [XHLaunchImageAdConfiguration defaultConfiguration];
//广告图片URLString/或本地图片名(.jpg/.gif请带上后缀)
imageAdconfiguration.imageNameOrURLString = model.content;
//广告点击打开链接
imageAdconfiguration.openURLString = model.openUrl;
//广告点击打开页面参数(openModel可为NSString,模型,字典等任意类型)
imageAdconfiguration.openModel = model.openUrl;
//显示开屏广告
[XHLaunchAd imageAdWithImageAdConfiguration:imageAdconfiguration delegate:self];
Expand Down Expand Up @@ -195,8 +196,8 @@
imageAdconfiguration.imageOption = XHLaunchAdImageDefault;
//图片填充模式
imageAdconfiguration.contentMode = UIViewContentModeScaleToFill;
//广告点击打开链接
imageAdconfiguration.openURLString = model.openUrl;
//广告点击打开页面参数(openModel可为NSString,模型,字典等任意类型)
imageAdconfiguration.openModel = model.openUrl;
//广告显示完成动画
imageAdconfiguration.showFinishAnimate =ShowFinishAnimateLite;
//广告显示完成动画时间
Expand Down Expand Up @@ -229,8 +230,8 @@
XHLaunchVideoAdConfiguration *videoAdconfiguration = [XHLaunchVideoAdConfiguration defaultConfiguration];
//广告视频URLString/或本地视频名(请带上后缀)
videoAdconfiguration.videoNameOrURLString = @"video0.mp4";
//广告点击打开链接
videoAdconfiguration.openURLString = @"http://www.it7090.com";
//广告点击打开页面参数(openModel可为NSString,模型,字典等任意类型)
videoAdconfiguration.openModel = @"http://www.it7090.com";
//显示视频开屏广告
[XHLaunchAd videoAdWithVideoAdConfiguration:videoAdconfiguration delegate:self];
```
Expand All @@ -254,8 +255,8 @@
videoAdconfiguration.scalingMode = MPMovieScalingModeAspectFill;
//是否只循环播放一次
videoAdconfiguration.videoCycleOnce = NO;
//广告点击打开链接
videoAdconfiguration.openURLString = @"http://www.it7090.com";
//广告点击打开页面参数(openModel可为NSString,模型,字典等任意类型)
videoAdconfiguration.openModel = @"http://www.it7090.com";
//广告显示完成动画
videoAdconfiguration.showFinishAnimate =ShowFinishAnimateFadein;
//广告显示完成动画时间
Expand Down Expand Up @@ -298,8 +299,8 @@
XHLaunchVideoAdConfiguration *videoAdconfiguration = [XHLaunchVideoAdConfiguration defaultConfiguration];
//注意:视频广告只支持先缓存,下次显示(看效果请二次运行)
videoAdconfiguration.videoNameOrURLString = model.content;
//广告点击打开链接
videoAdconfiguration.openURLString = model.openUrl;
//广告点击打开页面参数(openModel可为NSString,模型,字典等任意类型)
videoAdconfiguration.openModel = model.openUrl;
[XHLaunchAd videoAdWithVideoAdConfiguration:videoAdconfiguration delegate:self];
} failure:^(NSError *error) {
Expand Down Expand Up @@ -341,8 +342,8 @@
videoAdconfiguration.scalingMode = MPMovieScalingModeAspectFill;
//是否只循环播放一次
videoAdconfiguration.videoCycleOnce = NO;
//广告点击打开链接
videoAdconfiguration.openURLString = model.openUrl;
//广告点击打开页面参数(openModel可为NSString,模型,字典等任意类型)
videoAdconfiguration.openModel = model.openUrl;
//广告显示完成动画
videoAdconfiguration.showFinishAnimate =ShowFinishAnimateFadein;
//广告显示完成动画时间
Expand Down Expand Up @@ -408,16 +409,25 @@ typedef NS_ENUM(NSInteger,SkipType) {

### 2.点击事件
```objc

/**
* 广告点击事件 回调
*/
- (void)xhLaunchAd:(XHLaunchAd *)launchAd clickAndOpenURLString:(NSString *)openURLString;
{
广告点击事件回调
*/
-(void)xhLaunchAd:(XHLaunchAd *)launchAd clickAndOpenModel:(id)openModel clickPoint:(CGPoint)clickPoint{

NSLog(@"广告点击事件");

/**
openModel即配置广告数据设置的点击广告时打开页面参数
*/
NSString *urlString = (NSString *)openModel;

//跳转到广告详情页面,详见demo
WebViewController *VC = [[WebViewController alloc] init];
VC.URLString = openURLString;
.....
//此处跳转页面
//WebViewController *VC = [[WebViewController alloc] init];
//VC.URLString = urlString;
////此处不要直接取keyWindow
//UIViewController* rootVC = [[UIApplication sharedApplication].delegate window].rootViewController;
//[rootVC.myNavigationController pushViewController:VC animated:YES];

}

Expand Down Expand Up @@ -612,7 +622,7 @@ configuration.customSkipView = [self customSkipView];
}

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

```

## 常见问题
#### 1.为什么设置了本地图片广告,却提示找不到图片资源?
* 请将本地广告图片,直接放在工程目录,不要放在Assets里面,XHLaunchAd不是通过imageName:读取图片,而是是通过[NSBundle mainBundle] path....的方式读取本地图片的(此处涉及到内存优化)

#### 2.为什么我启动的时候会先进入根控制器后,再显示广告页面?
* 请确认下,你在请求广告数据之前,是否有调用`[XHLaunchAd setWaitDataDuration:3];`方法设置数据等待时间

#### 3.为什么有时候我会卡在启动广告页面(偶现)?
* 此情况多出现在网络环境差时,请检查你程序启动时,有没有掉用同步方法或同步请求,(例如:环信SDK同步登录等),
* XHLaunchAd采用GCD定时器,不受主线程阻塞影响,但是GCD倒计时到后,广告移除实在主线程中进行的.


## 依赖
#### 1.本库依赖于:FLAnimatedImage

Expand Down
2 changes: 1 addition & 1 deletion XHLaunchAd.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "XHLaunchAd"
s.version = "3.8.4"
s.version = "3.9.0"
s.summary = "The screen opening advertising solutions - 开屏广告、启动广告解决方案,支持图片/视频、静态/动态、全屏/半屏广告,支持iPhone/iPad,自带图片下载、缓存功能,等等."
s.homepage = "https://github.com/CoderZhuXH/XHLaunchAd"
s.license = { :type => "MIT", :file => "LICENSE" }
Expand Down
42 changes: 14 additions & 28 deletions XHLaunchAd/XHLaunchAd/XHLaunchAd.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// Copyright © 2016年 it7090.com. All rights reserved.
// 代码地址:https://github.com/CoderZhuXH/XHLaunchAd

// 版本:3.8.4
// 发布:2017.11.14
// 版本:3.9.0
// 发布:2017.11.22

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

/**
* 广告点击
*
* @param launchAd launchAd
* @param openURLString 打开页面地址
*/
- (void)xhLaunchAd:(XHLaunchAd *)launchAd clickAndOpenURLString:(NSString *)openURLString;

/**
* 广告点击 - 并回调点击位置(此方法与上面方法无本质区别,只是多回调一个参数[点击位置],二者实现其一即可,注意:若两者都实现,只有此方法会被执行)
广告点击
* @param launchAd launchAd
* @param openURLString 打开页面地址
* @param clickPoint 点击位置
*/
- (void)xhLaunchAd:(XHLaunchAd *)launchAd clickAndOpenURLString:(NSString *)openURLString clickPoint:(CGPoint)clickPoint;

/**
* 图片本地读取/或下载完成回调
*
* @param launchAd XHLaunchAd
* @param image 读取/下载的image
@param launchAd launchAd
@param openModel 打开页面参数(此参数即你配置广告数据设置的configuration.openModel)
@param clickPoint 点击位置
*/
-(void)xhLaunchAd:(XHLaunchAd *)launchAd imageDownLoadFinish:(UIImage *)image;
- (void)xhLaunchAd:(XHLaunchAd *)launchAd clickAndOpenModel:(id)openModel clickPoint:(CGPoint)clickPoint;

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

#pragma mark - 过期
/** 请使用xhLaunchAdShowFinish: */
-(void)xhLaunchShowFinish:(XHLaunchAd *)launchAd;

#pragma mark - 过期-XHLaunchAdDelegate
- (void)xhLaunchAd:(XHLaunchAd *)launchAd clickAndOpenURLString:(NSString *)openURLString XHLaunchAdDeprecated("请使用xhLaunchAd:clickAndOpenPageModel:clickPoint:");
- (void)xhLaunchAd:(XHLaunchAd *)launchAd clickAndOpenURLString:(NSString *)openURLString clickPoint:(CGPoint)clickPoint XHLaunchAdDeprecated("请使用xhLaunchAd:clickAndOpenPageModel:clickPoint:");
-(void)xhLaunchAd:(XHLaunchAd *)launchAd imageDownLoadFinish:(UIImage *)image XHLaunchAdDeprecated("请使用xhLaunchAd:imageDownLoadFinish:imageData:");
-(void)xhLaunchShowFinish:(XHLaunchAd *)launchAd XHLaunchAdDeprecated("请使用xhLaunchAdShowFinish:");

@end

@interface XHLaunchAd : NSObject
Expand Down Expand Up @@ -283,9 +271,7 @@ NS_ASSUME_NONNULL_BEGIN
+(NSString *)xhLaunchAdCachePath;

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

@end
Expand Down
38 changes: 25 additions & 13 deletions XHLaunchAd/XHLaunchAd/XHLaunchAd.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,16 @@ @interface XHLaunchAd()
@property(nonatomic,copy)dispatch_source_t skipTimer;
@property (nonatomic, assign) BOOL detailPageShowing;
@property(nonatomic,assign) CGPoint clickPoint;


@end

@implementation XHLaunchAd

+(void)setLaunchSourceType:(SourceType)sourceType{
_sourceType = sourceType;
}
+(void)setWaitDataDuration:(NSInteger )waitDataDuration{
XHLaunchAd *launchAd = [XHLaunchAd shareLaunchAd];
launchAd.waitDataDuration = waitDataDuration;
}
+(void)setLaunchSourceType:(SourceType)sourceType{
_sourceType = sourceType;
}

+(XHLaunchAd *)imageAdWithImageAdConfiguration:(XHLaunchImageAdConfiguration *)imageAdconfiguration{
return [XHLaunchAd imageAdWithImageAdConfiguration:imageAdconfiguration delegate:nil];
}
Expand Down Expand Up @@ -232,9 +228,12 @@ -(void)setupImageAdForConfiguration:(XHLaunchImageAdConfiguration *)configuratio
XHWeakSelf
[adImageView xh_setImageWithURL:[NSURL URLWithString:configuration.imageNameOrURLString] placeholderImage:nil GIFImageCycleOnce:configuration.GIFImageCycleOnce options:configuration.imageOption completed:^(UIImage *image,NSData *imageData,NSError *error,NSURL *url){
if(!error){
#pragma clang diagnostic push
#pragma clang diagnostic ignored"-Wdeprecated-declarations"
if ([weakSelf.delegate respondsToSelector:@selector(xhLaunchAd:imageDownLoadFinish:)]) {
[weakSelf.delegate xhLaunchAd:self imageDownLoadFinish:image];
}
#pragma clang diagnostic pop
if ([weakSelf.delegate respondsToSelector:@selector(xhLaunchAd:imageDownLoadFinish:imageData:)]) {
[weakSelf.delegate xhLaunchAd:self imageDownLoadFinish:image imageData:imageData];
}
Expand Down Expand Up @@ -264,9 +263,12 @@ -(void)setupImageAdForConfiguration:(XHLaunchImageAdConfiguration *)configuratio
adImageView.animatedImage = nil;
adImageView.image = [UIImage imageWithData:data];
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored"-Wdeprecated-declarations"
if ([self.delegate respondsToSelector:@selector(xhLaunchAd:imageDownLoadFinish:)]) {
[self.delegate xhLaunchAd:self imageDownLoadFinish:[UIImage imageWithData:data]];
}
#pragma clang diagnostic pop
}else{
XHLaunchAdLog(@"未设置广告图片");
}
Expand Down Expand Up @@ -399,21 +401,27 @@ -(void)removeAndAnimated:(BOOL)animated{
if(animated){
[self removeAndAnimate];
}else{
[self removeAndAnimateDefault];
[self remove];
}
}

-(void)clickAndPoint:(CGPoint)point{
self.clickPoint = point;
XHLaunchAdConfiguration * configuration = [self commonConfiguration];
#pragma clang diagnostic push
#pragma clang diagnostic ignored"-Wdeprecated-declarations"
if ([self.delegate respondsToSelector:@selector(xhLaunchAd:clickAndOpenURLString:)] && configuration.openURLString.length) {
[self.delegate xhLaunchAd:self clickAndOpenURLString:configuration.openURLString];
[self removeAndAnimateDefault];
}
if ([self.delegate respondsToSelector:@selector(xhLaunchAd:clickAndOpenURLString:clickPoint:)] && configuration.openURLString.length) {
[self.delegate xhLaunchAd:self clickAndOpenURLString:configuration.openURLString clickPoint:point];
[self removeAndAnimateDefault];
}else{
if ([self.delegate respondsToSelector:@selector(xhLaunchAd:clickAndOpenURLString:)] && configuration.openURLString.length) {
[self.delegate xhLaunchAd:self clickAndOpenURLString:configuration.openURLString];
[self removeAndAnimateDefault];
}
}
#pragma clang diagnostic pop
if ([self.delegate respondsToSelector:@selector(xhLaunchAd:clickAndOpenModel:clickPoint:)] && configuration.openModel) {
[self.delegate xhLaunchAd:self clickAndOpenModel:configuration.openModel clickPoint:point];
[self removeAndAnimateDefault];
}
}

Expand Down Expand Up @@ -561,9 +569,13 @@ -(void)remove{
}];
_window.hidden = YES;
_window = nil;

#pragma clang diagnostic push
#pragma clang diagnostic ignored"-Wdeprecated-declarations"
if ([self.delegate respondsToSelector:@selector(xhLaunchShowFinish:)]) {
[self.delegate xhLaunchShowFinish:self];
}
#pragma clang diagnostic pop
if ([self.delegate respondsToSelector:@selector(xhLaunchAdShowFinish:)]) {
[self.delegate xhLaunchAdShowFinish:self];
}
Expand Down
12 changes: 7 additions & 5 deletions XHLaunchAd/XHLaunchAd/XHLaunchAdButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

/** Progress颜色 */
#define RoundProgressColor [UIColor whiteColor]
/** 背景色 */
#define BackgroundColor [UIColor colorWithRed:0 green:0 blue:0 alpha:0.4]
/** 字体颜色 */
#define FontColor [UIColor whiteColor]

#define SkipTitle @"跳过"
/** 倒计时单位 */
Expand Down Expand Up @@ -72,13 +76,11 @@ - (instancetype)initWithSkipType:(SkipType)skipType{
break;
case SkipTypeRoundProgressTime:{
[self addSubview:self.timeLab];
self.timeLab.backgroundColor = [UIColor clearColor];
[self.timeLab.layer addSublayer:self.roundLayer];
}
break;
case SkipTypeRoundProgressText:{
[self addSubview:self.timeLab];
self.timeLab.backgroundColor = [UIColor clearColor];
[self.timeLab.layer addSublayer:self.roundLayer];
}
break;
Expand All @@ -92,8 +94,8 @@ - (instancetype)initWithSkipType:(SkipType)skipType{
-(UILabel *)timeLab{
if(_timeLab == nil){
_timeLab = [[UILabel alloc] initWithFrame:self.bounds];
_timeLab.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.4];
_timeLab.textColor = [UIColor whiteColor];
_timeLab.textColor = FontColor;
_timeLab.backgroundColor = BackgroundColor;
_timeLab.layer.masksToBounds = YES;
_timeLab.textAlignment = NSTextAlignmentCenter;
_timeLab.font = [UIFont systemFontOfSize:13.5];
Expand All @@ -105,7 +107,7 @@ -(UILabel *)timeLab{
-(CAShapeLayer *)roundLayer{
if(_roundLayer==nil){
_roundLayer = [CAShapeLayer layer];
_roundLayer.fillColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.4].CGColor;
_roundLayer.fillColor = BackgroundColor.CGColor;
_roundLayer.strokeColor = RoundProgressColor.CGColor;
_roundLayer.lineCap = kCALineCapRound;
_roundLayer.lineJoin = kCALineJoinRound;
Expand Down
Loading

0 comments on commit 03ae081

Please sign in to comment.