In
most of the Apps we display the ads. Most of us have
displayed the ads using different ad networks like
adMob,iAd etc. Today, I will provide the details to
integrate iAds in your app using swift.
The first requirement to display the iAd is to import the iAd framework. In swift you can import it by following way.
import iAd
The first requirement to display the iAd is to import the iAd framework. In swift you can import it by following way.
import iAd
Once you have import the framework, you can display the iAd by writing single line in view did load.
override func viewDidLoad()
{
super.viewDidLoad()
//
Do any additional setup after loading the view, typically from a nib.
self.canDisplayBannerAds
= true
}
As soon as you set the property true, your app will be able to display the ads if iAd inventory will be available.
Note: Make sure that you write this line in viewDidLoad only.
As soon as you set the property true, your app will be able to display the ads if iAd inventory will be available.
Note: Make sure that you write this line in viewDidLoad only.
To determine the success or failure of iAd you have to implement ADBannerViewDelegate protocol that provides the callback when ad will load successfully or will fail.
func bannerViewDidLoadAd(banner: ADBannerView!) {
println("success")
}
func bannerView(banner: ADBannerView!, didFailToReceiveAdWithError
error: NSError!) {
println("failed to load ad")
banner.removeFromSuperview() //Remove the banner if you have added it as subview (No ad)
}
This
was a simple way to display the ads but it will display the ad in the
bottom of your UI and reduce the view height when it will be loaded.
Now
what you will do if you have to show it on the top of the screen ?
Don't worry I will also make it easy for you.
For
displaying the iAd on top of the view or any custom position, you have to
create a ADBannerView and add it in your view.
bannerV
= ADBannerView(adType:
ADAdType.Banner);
bannerV.frame
= CGRect(x:
0, y: 0,
width: 320,
height: 50);
bannerV.delegate
= self;
self.view.addSubview(bannerV)
Here is sample project with all the code of the above tutorial.
If you face any issue or have any suggestions, you can leave your comment.
Afyon
ReplyDeleteAntalya
Erzurum
Mersin
izmir
H0İ104
sivas evden eve nakliyat
ReplyDeleteerzurum evden eve nakliyat
bitlis evden eve nakliyat
mardin evden eve nakliyat
rize evden eve nakliyat
Z70NA5
DA093
ReplyDeleteTekirdağ Boya Ustası
Ünye Oto Boya
Kilis Evden Eve Nakliyat
İstanbul Şehirler Arası Nakliyat
Düzce Evden Eve Nakliyat
Erzurum Şehir İçi Nakliyat
Edirne Parça Eşya Taşıma
Çerkezköy Korkuluk
Ünye Mutfak Dolabı
3E703
ReplyDeleteorder sustanon
Tekirdağ Cam Balkon
testosterone propionat
Silivri Cam Balkon
sustanon
Ordu Evden Eve Nakliyat
halotestin
Eskişehir Evden Eve Nakliyat
buy parabolan
5CC46
ReplyDeleteBilecik Şehirler Arası Nakliyat
Ünye Petek Temizleme
Silivri Çatı Ustası
Urfa Lojistik
Yenimahalle Boya Ustası
Mexc Güvenilir mi
Burdur Parça Eşya Taşıma
Mamak Boya Ustası
Maraş Evden Eve Nakliyat
E8EDB
ReplyDeleteHakkari Lojistik
Malatya Lojistik
Rize Parça Eşya Taşıma
Sivas Şehirler Arası Nakliyat
Bitrue Güvenilir mi
Osmaniye Şehirler Arası Nakliyat
Aksaray Şehir İçi Nakliyat
Yozgat Evden Eve Nakliyat
Kilis Parça Eşya Taşıma
EE4F6
ReplyDeletebinance
B7559
ReplyDeleteaydın telefonda sohbet
mobil sohbet odaları
kilis en iyi rastgele görüntülü sohbet
Antalya Bedava Görüntülü Sohbet Sitesi
bitlis kadınlarla ücretsiz sohbet
bedava sohbet uygulamaları
rastgele görüntülü sohbet ücretsiz
Afyon Rastgele Canlı Sohbet
Bitlis Görüntülü Sohbet Odaları
CE98D
ReplyDeleteKripto Para Kazanma
Tumblr Beğeni Hilesi
Soundcloud Takipçi Hilesi
Kripto Para Nasıl Üretilir
Soundcloud Takipçi Satın Al
Binance Borsası Güvenilir mi
Wabi Coin Hangi Borsada
Apenft Coin Hangi Borsada
Kripto Para Çıkarma
شركة تنظيف افران بعنيزة auDsFX6qjW
ReplyDeleteتسليك مجاري بالهفوف LSyn9dlaYC
ReplyDeleteشركة مكافحة الصراصير بالاحساء XwhEMARfAW
ReplyDeleteشركة تنظيف خزانات mdIJ50fvvk
ReplyDeleteشركة مكافحة حشرات بخميس مشيط d78yNlkuYQ
ReplyDelete