Coder Social home page Coder Social logo

mqzhot / zlaunchad Goto Github PK

View Code? Open in Web Editor NEW
429.0 13.0 72.0 20.9 MB

快速集成启动广告,支持LaunchImage和LaunchScreen,支持GIF,支持本地图片,支持视图过渡动画

License: MIT License

Swift 91.27% Ruby 1.46% Objective-C 7.05% C 0.21%
storyboard launchad launchimage swift launch

zlaunchad's Introduction

ZLaunchAd

image image Carthage Compatible image ZLaunchAd集成启动广告,支持LaunchImageLaunchScreen,支持GIF,支持本地图片,支持视图过渡动画

image image image image image image

功能

  • 支持进入前台广告显示,设定时间间隔,进入后台后返回的时间大于间隔才进行显示
  • 接收自定义通知控制图片显示
  • 支持Objective-C/Swift
  • 自带图片缓存,清除缓存
  • 自定义跳过按钮外观、位置
  • 支持网络/本地资源,支持GIF图片显示
  • 支持LaunchImage和LaunchScreen.storyboard.
  • 支持广告点击事件,支持广告完成动画设置

安装

CocoaPods

platform :ios, '8.0'
use_frameworks!

target 'YourTargetName' do
pod 'ZLaunchAd'
end

Carthage

github "MQZHot/ZLaunchAd"

Swift Package Manager

import PackageDescription

let package = Package(
    name: "YOUR_PROJECT_NAME",
    dependencies: [
        .package(url: "https://github.com/MQZHot/ZLaunchAd.git", from: "2.1.0"),
    ]
)

使用

/// 进入前台时显示
func create(waitTime: Int = 3, showEnterForeground: Bool = false, timeForWillEnterForeground: Double = 10, adNetRequest: ((ZLaunchAdView)->())? = nil) -> ZLaunchAdView
/// 自定义通知控制出现
func create(waitTime: Int = 3, customNotificationName: String?, adNetRequest: ((ZLaunchAdView)->())? = nil) -> ZLaunchAdView

配置图片资源----配置跳过按钮

func setImageResource(_ imageResource: ZLaunchAdImageResourceConfigure, buttonConfig: ZLaunchSkipButtonConfig? = nil, action: ZLaunchClosure?)

页面配置

  • ZLaunchSkipButtonConfig:跳过按钮配置
  • ZLaunchAdImageResourceConfigure:配置广告图

清除缓存

/// 清除全部缓存
ZLaunchAd.clearDiskCache()

/// 清除指定url的缓存
let array = ["http://..", "http://..", "http://..", "http://.."]
ZLaunchAd.clearDiskCacheWithImageUrlArray(array)

联系

zlaunchad's People

Contributors

lintx avatar mqzhot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zlaunchad's Issues

Redefinition of module 'CommonCrypto'

升级 XCode 10 后,报以下错误

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/usr/include/CommonCrypto/module.modulemap:1:8: Redefinition of module 'CommonCrypto'

carthage xcode10 报错

error: no such module 'CCommonCrypto'
import CCommonCrypto
^

** ARCHIVE FAILED **

The following build commands failed:
CompileSwift normal arm64
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler

网络不好导致的卡在广告页

private func image(url: URL, cache: Bool, completion:@escaping (UIImage?)->()) {

        guard let imageData = try? Data(contentsOf: url) else {
            return
        }
        if cache {
            saveImage(imageData, url: url, completion: nil)/// 存储
        }
        let image = self.image(data: imageData)
        completion(image)
    
}

在网络不好的情况下,下载缓慢,会卡在这里,

endOfCountDown

这个函数是你新加的吗,提一下cocoapod呗

建议 UIApplicationWillEnterForeground 增加时间间隔的指定或者增加自定义事件的支持

很方便,谢谢!

不过目前设置 showEnterForeground 为 true 时,每次 UIApplicationWillEnterForeground 都会进行触发,对于某些场景来说过于频繁。

建议在 showEnterForeground 为 true 时同时接受一个间隔时间,只有进入后台后返回的时间大于间隔才进行显示。

更自由的一个方案是接受自定义 NSNotification.Name 事件,需要展示时用户自行发送事件进行触发。

请参考

launchImageView 某些情况下是空白

launchImageView 某些情况下是空白,把111的图片换了就出现这种情况,storyboardLaunchImage() 数据是有,但是显示是空白 (Demo显示是正常,但是Demo的一换图片就出现这种情况,不确定是模拟器的原因还是其他)

进不去

2018-07-16 15:39:05.476780+0800 redou[21518:1753128] [Debug] [main] [MYPWalkThroughVC.swift:16] viewDidLoad() > Run walk.
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:3
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:2
ZLaunchAdCache.swift[75], createBaseDirectoryAtPath: ZLaunchAd cache directory = 
/var/mobile/Containers/Data/Application/C1BEA3DB-8141-42AD-AFA4-BC74E6D0C86A/Library
/ZLaunchAdCache
ZLaunchAdCache.swift[58], getCacheImageWithURL: 
Error Domain=NSCocoaErrorDomain Code=260 "
The file “F3AFE0B0A143B45CFED8C180C54A496A” couldn’t be opened because there is no such file." 
UserInfo={NSFilePath=/var/mobile/Containers/Data/Application/C1BEA3DB-8141-42AD-AFA4-BC74E6D0C86A/Library/
ZLaunchAdCache/F3AFE0B0A143B45CFED8C180C54A496A, 
NSUnderlyingError=0x10fb31510 {Error Domain=NSPOSIXErrorDomain Code=2 
"No such file or directory"}}
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:1
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等等\345\276待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0
ZLaunchAdView.swift[196], startTimer(): 等待加载计时:0

进不去。

提几点优化建议:

  1. 希望可以实现在create的返回的ZLaunchAdView上添加新的控件。
  2. 希望添加下广告等待时间的监听,这样有利于实现其他的业务操作。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.