Giter VIP home page Giter VIP logo

sitemajiwebadios's Introduction

SiteMaji Web AD 2.2.0

Installation Web AD Compoment

複製 SMJWebADHandler.swift 到專案中

Example Usage

sample code

宣告

//裝廣告用的容器
var adView:UIView = UIView()
//init web廣告
let adManager = SMJWebADHandler.sharedInstance
//廣告 url,此為測試用網址,正式上線時請記得換回正確的網址
let adUrl:String = "https://test.sitemaji.com/native/sitemaji.html?s=300x250"
//300x250廣告
//廣告view預定放置位置及大小
let adViewFrame:CGRect = CGRect.init(x: 0, y: 0, width: 300, height: 250)
//handle ad delegate
adManager.delegate = self
    
/*
指定一個view來裝廣告
 - Parameters:
 - adUrl: 廣告網址。
 - frame: 廣告view大小。
 - isShowCloseButton: 用來控制是否要出現close button,預設為false,可以自已客製外框及關閉按鈕
 */
adView = adManager.adView(adUrl: adUrl,frame: adViewFrame,isShowCloseButton: true)

//可自行決定廣告要放在哪
adView.center = self.view.center
    
self.view.addSubview(adView)
Implement Delegate in ViewController
#pragma mark - SMJWebADHandler Delegate

//點擊廣告時callback
func adDidClick() {
    print("ad did click")

}
//廣告讀取有問題時callback
func adFetchError(errorMsg: String) {
    print("error:\(errorMsg)")
}
    
//廣告關閉按鈕被點擊時,此為optional,isShowCloseButton設為true時請記得實作
func adCloseClick() {
    print("ad close button did click")
    adView.removeFromSuperview()
}

drawing

sitemajiwebadios's People

Contributors

ck00031 avatar

Watchers

Tsung avatar  avatar Ting Cheng avatar James Cloos avatar bc avatar

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.