An example of an addition to the swift version of Adbannerview ads

Source: Internet
Author: User

Apple's official advertising has 4 kinds, today introduced Adbannerview, that is, the common bar-style ads

Development process

I. Application

In the itunes connect to apply for advertising permission, this Google will have, a lot of tutorials!! When setting up the bank card, to inquire "modern payment system line number", can be found in this page of Zhejiang Merchant Bank Https://e.czbank.com/CORPORBANK/QYUK

Second, the Code

By adding the IAD framework, you can add the IAD framework to the "Build Phase" setting "Link Binary with Libaries", or you can import iad directly into your code
In the storyboard, drag a iad bannerview build, place it in a view that you've prepared, and then line up the variables in the corresponding program
Class inheritance Adbannerviewdelegate Agent
Add self.candisplaybannerads = True in the Viewdidload function
Complete the necessary functions to monitor the status of each ad completed
Specific code

The code is as follows Copy Code

Import Uikit
Import IAd

Class Secviewcontroller:uiviewcontroller,adbannerviewdelegate {

@IBOutlet weak var view1:uiview!
Line variables for AD view
@IBOutlet weak var ad:adbannerview!

Override Func Viewdidload () {
Super.viewdidload ()
Self.candisplaybannerads = True
Ad.frame = View1.bounds
Self.ad.delegate = Self

}

Override Func didreceivememorywarning () {
Super.didreceivememorywarning ()
Dispose of any of the can is recreated.
}

Func Bannerviewdidloadad (banner:adbannerview!) {
Self.ad.hidden = False
println ("Success")
}

Func Bannerviewactionshouldbegin (banner:adbannerview!, willleaveapplication willleave:bool)-> Bool {
Return Willleave
}

Func Bannerview (banner:adbannerview!, Didfailtoreceiveadwitherror error:nserror!) {
println ("Failed")
}

}

Problem

The simulator is also able to debug the ad code, can display the advertisement
Sometimes do not show, there may be the problem of network speed

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.