Google Mobile Ads SDK תומך בגדלים קבועים של מודעות במצבים שבהם מודעות מותאמות מודעות באנר לא מתאימות לצרכים שלכם.
בטבלה הבאה מפורטים הגדלים הרגילים של מודעות הבאנר.
גודל ב-dp (WxH) | תיאור | זמינות | קבוע של גודל המודעה |
---|---|---|---|
320x50 | כרזה | טלפונים וטאבלטים | GADAdSizeBanner |
320x100 | מודעת באנר גדולה | טלפונים וטאבלטים | GADAdSizeLargeBanner |
300x250 | מלבן בינוני של IAB | טלפונים וטאבלטים | GADAdSizeMediumRectangle |
468x60 | מודעת באנר בגודל מלא של IAB | טאבלטים | GADAdSizeFullBanner |
728x90 | לוח הישגי השחקנים המובילים של IAB | טאבלטים | GADAdSizeLeaderboard |
כדי להגדיר גודל באנר מותאם אישית, מגדירים את הגודל באמצעות GADAdSizeFromCGSize
:
Swift
let adSize = GADAdSizeFromCGSize(CGSize(width: 250, height: 250))
Objective-C
GADAdSize size = GADAdSizeFromCGSize(CGSizeMake(250, 250));
דוגמה למודעות באנר בגודל קבוע
גודל מודעה מותאם אישית
בנוסף ליחידות המודעות הרגילות, ניתן להציג ב-Google Ad Manager כל גודל
של יחידת מודעות מסוימת באפליקציה. גודל המודעה (רוחב, גובה) שהוגדר לבקשה להצגת מודעה
צריך להתאים למידות של תצוגת המודעה (GAMBannerView
) המוצגות
אפליקציה. כדי להגדיר גודל מותאם אישית, משתמשים ב-GADAdSizeFromCGSize
.
Swift
// Define custom GADAdSize of 250x250 for GAMBannerView.
let customAdSize = GADAdSizeFromCGSize(CGSize(width: 250, height: 250))
bannerView = GAMBannerView(adSize: customAdSize)
Objective-C
// Define custom GADAdSize of 250x250 for GAMBannerView
GADAdSize customAdSize = GADAdSizeFromCGSize(CGSizeMake(250, 250));
self.bannerView = [[GAMBannerView alloc] initWithAdSize:customAdSize];
גדלים מרובים של מודעות
ב-Ad Manager אפשר לציין כמה גדלים של מודעות שיכולים להיות כשירות להצגה.
לGAMBannerView
. כדי להשתמש בהגדרה הזו, צריך לבצע שלושה שלבים
פיצ'ר:
בממשק המשתמש של Ad Manager, יוצרים פריט טירגוט לאותה יחידת מודעות שמשויכת לקריאייטיבים בגדלים שונים.
באפליקציה שלך, צריך להגדיר את המאפיין
validAdSizes
ב-GAMBannerView
:Swift
// Define an optional array of GADAdSize to specify all valid sizes that are appropriate // for this slot. Never create your own GADAdSize directly. Use one of the // predefined standard ad sizes (such as GADAdSizeBanner), or create one using // the GADAdSizeFromCGSize method. // // Note: Ensure that the allocated GAMBannerView is defined with an ad size. Also note // that all desired sizes should be included in the validAdSizes array. bannerView.validAdSizes = [NSValueFromGADAdSize(GADAdSizeBanner), NSValueFromGADAdSize(GADAdSizeMediumRectangle), NSValueFromGADAdSize(GADAdSizeFromCGSize(CGSize(width: 120, height: 20)))]
Objective-C
// Define an optional array of GADAdSize to specify all valid sizes that are appropriate // for this slot. Never create your own GADAdSize directly. Use one of the // predefined standard ad sizes (such as GADAdSizeBanner), or create one using // the GADAdSizeFromCGSize method. // // Note: Ensure that the allocated GAMBannerView is defined with an ad size. Also note // that all desired sizes should be included in the validAdSizes array. self.bannerView.validAdSizes = @[ NSValueFromGADAdSize(GADAdSizeBanner), NSValueFromGADAdSize(GADAdSizeMediumRectangle), NSValueFromGADAdSize(GADAdSizeFromCGSize(CGSizeMake(120, 20))) ];
מטמיעים את השיטה
GADAdSizeDelegate
כדי לזהות שינוי בגודל המודעה.Swift
public func bannerView(_ bannerView: GADBannerView, willChangeAdSizeTo size: GADAdSize)
Objective-C
- (void)bannerView:(GAMBannerView *)view willChangeAdSizeTo:(GADAdSize)size;
חשוב לזכור להגדיר את הגורם המורשה לפני שליחת הבקשה להצגת מודעה.
Swift
bannerView.adSizeDelegate = self
Objective-C
self.bannerView.adSizeDelegate = self;