###静态广告 /动态广告
##API
/** * 显示启动广告 * * @param frame 广告 frame * @param setAdImage 设置 AdImage 回调 * @param showFinish 广告显示完成回调 */ +(void)showWithAdFrame:(CGRect)frame setAdImage:(setAdImageBlock)setAdImage showFinish:(showFinishBlock)showFinish;
/** * 设置广告数据 * * @param imageUrl 图片 url * @param duration 广告停留时间 * @param skipType 跳过按钮类型 * @param options 图片缓存机制 * @param completedBlock 异步加载完图片回调 * @param click 广告点击事件回调 */ -(void)setImageUrl:(NSString*)imageUrl duration:(NSInteger)duration skipType:(SkipType)skipType options:(XHWebImageOptions)options completed:(XHWebImageCompletionBlock)completedBlock click:(clickBlock)click;
//1.显示启动广告 [XHLaunchAd showWithAdFrame:CGRectMake(0, 0,self.window.bounds.size.width, self.window.bounds.size.height-150) setAdImage:^(XHLaunchAd *launchAd) { //未检测到广告数据,启动页停留时间,默认 3,(设置 4 即表示:启动页显示了 4s,还未检测到广告数据,就自动进入 window 根控制器) //launchAd.noDataDuration = 4; //广告图片地址 NSString *imgUrl = @"http://c.hiphotos.baidu.com/image/pic/item/d62a6059252dd42a6a943c180b3b5bb5c8eab8e7.jpg"; //广告停留时间 NSInteger duration = 6; //广告点击跳转链接 NSString *openUrl = @"http://www.returnoc.com"; //2.设置广告数据 [launchAd setImageUrl:imgUrl duration:duration skipType:SkipTypeTimeText options:XHWebImageDefault completed:^(UIImage *image, NSURL *url) { //异步加载图片完成回调,若需根据图片尺寸,刷新广告 frame,可在这里操作 //launchAd.adFrame = ...; } click:^{ //广告点击事件 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:openUrl]]; }]; } showFinish:^{ //广告展示完成回调,设置 window 根控制器 self.window.rootViewCOntroller= [[UINavigationController alloc] initWithRootViewController:[[UIViewController alloc] init]]; }];
/** * 设置未检测到广告数据,启动页停留时间(默认 3s)(最小 1s) */ @property (nonatomic, assign) NSInteger noDataDuration; /** * 重置广告 frame */ @property (nonatomic, assign) CGRect adFrame; /** * 清除图片本地缓存 */ +(void)clearDiskCache; /** * 获取缓存图片占用总大小(M) */ + (float)imagesCacheSize;
![]() | 1 newkengsir OP 如果发错节点 麻烦告知一下 ,谢谢 |