Google Mobile Ads SDK תומך בגדלים קבועים של מודעות למקרים שבהם מודעות באנר מותאמות לא עונות על הצרכים שלכם.
בטבלה הבאה מפורטים הגדלים הסטנדרטיים של מודעות באנר.
| גודל ב-dp (רוחב x גובה) | תיאור | זמינות | ערך קבוע של AdSize |
|---|---|---|---|
| 320x50 | מודעת באנר | טלפונים וטאבלטים | GADAdSizeBanner |
| 320x100 | מודעת באנר גדולה | טלפונים וטאבלטים | GADAdSizeLargeBanner |
| 300x250 | מלבן בינוני של IAB | טלפונים וטאבלטים | GADAdSizeMediumRectangle |
| 468x60 | באנר בגודל מלא של IAB | טאבלטים | GADAdSizeFullBanner |
| 728x90 | טבלת המובילים של IAB | טאבלטים | GADAdSizeLeaderboard |
כדי להגדיר גודל מותאם אישית של מודעת באנר, משתמשים ב-GADAdSizeFromCGSize:
Swift
let adSize = adSizeFor(cgSize: CGSize(width: 250, height: 250))
Objective-C
GADAdSize size = GADAdSizeFromCGSize(CGSizeMake(250, 250));
הגדרת גודל מודעה שקטן מגודל המסך של המכשיר או שווה לו.
כדי לקבוע את הגודל המקסימלי של המסך ב-iOS 26 ואילך, משתמשים במאפיין
UIWindowScene.effectiveGeometry.coordinateSpace. ב-iOS 18 ובגרסאות קודמות, משתמשים במאפיין UIWindowScene.coordinateSpace.
לפרטים על מגבלות הגודל, קראו את המאמר פתרון בעיות שקשורות לחשיפות שלא מולאו ב-Ad Manager.
דוגמה למודעות באנר בגודל קבוע
גודל מודעה בהתאמה אישית
בנוסף ליחידות המודעות הרגילות, ב-Google Ad Manager אפשר להציג באפליקציה יחידות מודעות בכל גודל. גודל המודעה (רוחב, גובה) שמוגדר לבקשה להצגת מודעה צריך להתאים לממדים של תצוגת המודעה (GAMBannerView) שמוצגת באפליקציה. כדי להגדיר גודל מותאם אישית, משתמשים ב-GADAdSizeFromCGSize.
Swift
// Define custom GADAdSize of 250x250 for GAMBannerView.
let customAdSize = adSizeFor(cgSize: 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(AdSizeBanner), NSValueFromGADAdSize(AdSizeMediumRectangle), NSValueFromGADAdSize(adSizeFor(cgSize: 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: BannerView, willChangeAdSizeTo size: AdSize)Objective-C
- (void)bannerView:(GAMBannerView *)view willChangeAdSizeTo:(GADAdSize)size;חשוב להגדיר את הנציג לפני ששולחים את הבקשה להצגת מודעה.
Swift
bannerView.adSizeDelegate = selfObjective-C
self.bannerView.adSizeDelegate = self;