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