When playing iAd ads at the bottom, what's the Y value?

Hi Joe,

I think the correct way to position an iAd banner on the bottom of the screen across all devices is to set y = display.contentHeight - display.screenOriginY - adHeight, where you set adHeight dynamically depending whether you’re on an iPhone or iPad.  However, if you don’t subtract adHeight, the banner will still be aligned at the bottom, because iAds won’t allow the banner to partially off screen.  That explains your results in case (2).

I haven’t used AdMob, so unfortunately I can’t speak to that.  What I can say confidently is that the y value for iAds does not correspond to the top of the banner, consistent with the API documentation (unless that y value would cause the banner to be partially or fully off screen, in which case it is moved on screen).

  • Andrew

@aukStudios

I tried with following code,

local screenW, screenH = display.contentWidth, display.contentHeightlocal local topY = display.screenOriginY local rightX = display.contentWidth - display.screenOriginX local bottomY = display.contentHeight - display.screenOriginY local leftX = display.screenOriginX local trueW = rightX -leftX local trueH = bottomY - topY if (myTools.isApplePad() == true) then     adHeight = 66 \* trueW/768 else     adHeight = 50 \* trueW/320 end     ads.show( "banner", { x=leftX, y=bottomY - adHeight } )

The y value is exactly the same as your “y = display.contentHeight - display.screenOriginY - adHeight”

This adHeight I am using should be correct because I use this calculation to determine the adHeight so I can put a webView in the rest of the screen. By using this adHeight, the webView & iAd ad can be put together into the screen without any “leftover” space.

However, when I test with iPhone 5S, if I change the y value to the code above, the iAd ad banner shows above the bottom. There is a space between the bottom of the ad and the bottom of the screen.

See, it’s very confusing…  :wacko:

@Corona

I really hope this can be addressed. I think showing ads plays a very important role for many apps and should get a higher priority. Thanks.

@joe528,

Why in your code are you setting the adHeight using trueW (width)?  Intuitively, if you’re going to make an adjustment like that, wouldn’t trueH (height) make more sense?

All I can say is that in my project (both my full project and a simple test project), I’m not having any problems placing the iAd banner at the exact bottom of the screen on any of the devices I’ve tested on (iPhone 4, iPhone 5, iPad 3).

  • Andrew

@aukStudios

I am using the width because 768 or 320 is the width. The ad size played by iAd is either 320(w) * 50(h) or 768(w) * 66(h). I have tested this code with webView object to fill the screen seamlessly. I think the calculation should be correct.

I have no problem in using iAd with iOS devices except in order to place iAd at the bottom, my calculation is different from what you suggested. And if I go with your formula, I cannot place it at the bottom from my testing. I feel confused about it, but it’s just one of the confusing things about Corona iOS/admob plugins.

The problem I am facing and confused is more complicated and I have showed the inconsistency from my testing with iAd & admob in iOS & Android devices in my earlier post. I really hope Corona can address them.

However, from my testing, it’s still not consistent, please see the following results for the inconsistency: (I am using the latest daily build - CoronaSDK 2013.2100 and my config.lua is 320x480, letterbox)

 

(1) If y = display.contentHeight, iAd shows at the bottom for iPad (because iPad’s display.screenOriginalY = 0), but for iPhone 5S, iAd shows above the bottom. For admob, it behaves the same as iAd.

 

(2) If y = display.contentHeight - display.screenOriginalY, iPad is fine for both iAd & admob (again, I think it’s because display.screenOriginal is 0 for iPad). For iPhone 5S, iAd shows at the exact bottom, which is good. But for admob, the ad shows above the bottom for iPhone 5S. 

 

Besides, admob shows below the bottom for Galaxy Tab 3. (part of the top area of admob ad shows up)

 

(3) If y = display.contentHeight - display.screenOriginalY  * 2 , admob shows correctly at the bottom for iPhone 5S, but below the bottom for Galaxy Tab 3. For Galaxy Tab 3, in order to show at the exact bottom, I found y = display.contentHeight - display.screenOriginalY  * 2 - 63  would do. (I don’t know how to get this number, 63. I started with 50 & 66, and adjusted one pixel at at a time to get 63.) BTW, display.screenOriginalY for Galaxy Tab 3 is -16.

 

The conclusions:

 

(1) For iAd, it still looks like it’s “bottom-aligning”, is this final?

 

(2) For admob, the y value behaves differently than iAd, why is that? is this intended behavior? What’s the rule?

 

(3) For admob, iOS device & Android device seem to behave differently? How to correctly calculate the y value to place admob at the exact bottom for both iOS & Android devices?

 

Please someone shed some light on this. I am about to release a new version with iAd & admob before iTunes closes for the holidays. It’s a total mess right now.    :unsure:  Thanks.

Here is my update:

I saw similar question in this thread: 

http://forums.coronalabs.com/topic/28563-iads/page-3

It is raised by “deleurapps”, but no one really answered his question why the following formula works to place the ad at the bottom of the screen. He posted code like this to show ads in the bottom

local adY = display.contentHeight - display.screenOriginY ads.show( "banner", { x=originx, y=adY } )

I have tested this code, and it does work. (@sirnemo, your code is actually the same, “display.contentHeight - display.screenOriginY*2 - 90” is 2 pixels difference than “display.contentHeight - display.screenOriginY”)

Anyway, I too have the same question as “deleurapps” has:

Why does this code work to place iads (including admob) at the bottom of the screen??  :o 

Can anyone in Corona explain this?

It’s really weird. For example, 

display.contentHeight - display.screenOriginY = 524 - (-44) = 568  for iPhone 5

Why would this work? 

Does Corona ad plugin make the ad become “bottom-aligned” automatically when the Y is over certain value??

Hi Joe,

You may be interested in this thread, specifically the last few posts: http://forums.coronalabs.com/topic/41760-iads-not-clickable-anyone-else-having-this-issue/page-2.

Previously it seems that the y value was bottom-aligning iAd banners, but now it’s top-aligning it, consistent with the API documentation.

  • Andrew

@aukStudios Thanks for letting me know about the thread. Are you sure it’s now top-aligning? From the y value calculation, it still looks like bottom-aligning. Following is my experiments, replied to that thread too.

It’s now very confusing about placing the ad at the bottom of the screen.

 

From dchan’s earlier post,

You’re correct they should align with the top of the ad and this has been changed.

 

Does it mean the ads should all align with the top now?

 

However, from my testing, it’s still not consistent, please see the following results for the inconsistency: (I am using the latest daily build - CoronaSDK 2013.2100 and my config.lua is 320x480, letterbox)

 

(1) If y = display.contentHeight, iAd shows at the bottom for iPad (because iPad’s display.screenOriginalY = 0), but for iPhone 5S, iAd shows above the bottom. For admob, it behaves the same as iAd.

 

(2) If y = display.contentHeight - display.screenOriginalY, iPad is fine for both iAd & admob (again, I think it’s because display.screenOriginal is 0 for iPad). For iPhone 5S, iAd shows at the exact bottom, which is good. But for admob, the ad shows above the bottom for iPhone 5S. 

 

Besides, admob shows below the bottom for Galaxy Tab 3. (part of the top area of admob ad shows up)

 

(3) If y = display.contentHeight - display.screenOriginalY  * 2 , admob shows correctly at the bottom for iPhone 5S, but below the bottom for Galaxy Tab 3. For Galaxy Tab 3, in order to show at the exact bottom, I found y = display.contentHeight - display.screenOriginalY  * 2 - 63  would do. (I don’t know how to get this number, 63. I started with 50 & 66, and adjusted one pixel at at a time to get 63.) BTW, display.screenOriginalY for Galaxy Tab 3 is -16.

 

The conclusions:

 

(1) For iAd, it still looks like it’s “bottom-aligning”, is this final?

 

(2) For admob, the y value behaves differently than iAd, why is that? is this intended behavior? What’s the rule?

 

(3) For admob, iOS device & Android device seem to behave differently? How to correctly calculate the y value to place admob at the exact bottom for both iOS & Android devices?

 

Please someone shed some light on this. I am about to release a new version with iAd & admob before iTunes closes for the holidays. It’s a total mess right now.   :unsure:  Thanks.

Hi Joe,

I think the correct way to position an iAd banner on the bottom of the screen across all devices is to set y = display.contentHeight - display.screenOriginY - adHeight, where you set adHeight dynamically depending whether you’re on an iPhone or iPad.  However, if you don’t subtract adHeight, the banner will still be aligned at the bottom, because iAds won’t allow the banner to partially off screen.  That explains your results in case (2).

I haven’t used AdMob, so unfortunately I can’t speak to that.  What I can say confidently is that the y value for iAds does not correspond to the top of the banner, consistent with the API documentation (unless that y value would cause the banner to be partially or fully off screen, in which case it is moved on screen).

  • Andrew

@aukStudios

I tried with following code,

local screenW, screenH = display.contentWidth, display.contentHeightlocal local topY = display.screenOriginY local rightX = display.contentWidth - display.screenOriginX local bottomY = display.contentHeight - display.screenOriginY local leftX = display.screenOriginX local trueW = rightX -leftX local trueH = bottomY - topY if (myTools.isApplePad() == true) then     adHeight = 66 \* trueW/768 else     adHeight = 50 \* trueW/320 end     ads.show( "banner", { x=leftX, y=bottomY - adHeight } )

The y value is exactly the same as your “y = display.contentHeight - display.screenOriginY - adHeight”

This adHeight I am using should be correct because I use this calculation to determine the adHeight so I can put a webView in the rest of the screen. By using this adHeight, the webView & iAd ad can be put together into the screen without any “leftover” space.

However, when I test with iPhone 5S, if I change the y value to the code above, the iAd ad banner shows above the bottom. There is a space between the bottom of the ad and the bottom of the screen.

See, it’s very confusing…  :wacko:

@Corona

I really hope this can be addressed. I think showing ads plays a very important role for many apps and should get a higher priority. Thanks.

@joe528,

Why in your code are you setting the adHeight using trueW (width)?  Intuitively, if you’re going to make an adjustment like that, wouldn’t trueH (height) make more sense?

All I can say is that in my project (both my full project and a simple test project), I’m not having any problems placing the iAd banner at the exact bottom of the screen on any of the devices I’ve tested on (iPhone 4, iPhone 5, iPad 3).

  • Andrew

@aukStudios

I am using the width because 768 or 320 is the width. The ad size played by iAd is either 320(w) * 50(h) or 768(w) * 66(h). I have tested this code with webView object to fill the screen seamlessly. I think the calculation should be correct.

I have no problem in using iAd with iOS devices except in order to place iAd at the bottom, my calculation is different from what you suggested. And if I go with your formula, I cannot place it at the bottom from my testing. I feel confused about it, but it’s just one of the confusing things about Corona iOS/admob plugins.

The problem I am facing and confused is more complicated and I have showed the inconsistency from my testing with iAd & admob in iOS & Android devices in my earlier post. I really hope Corona can address them.

However, from my testing, it’s still not consistent, please see the following results for the inconsistency: (I am using the latest daily build - CoronaSDK 2013.2100 and my config.lua is 320x480, letterbox)

 

(1) If y = display.contentHeight, iAd shows at the bottom for iPad (because iPad’s display.screenOriginalY = 0), but for iPhone 5S, iAd shows above the bottom. For admob, it behaves the same as iAd.

 

(2) If y = display.contentHeight - display.screenOriginalY, iPad is fine for both iAd & admob (again, I think it’s because display.screenOriginal is 0 for iPad). For iPhone 5S, iAd shows at the exact bottom, which is good. But for admob, the ad shows above the bottom for iPhone 5S. 

 

Besides, admob shows below the bottom for Galaxy Tab 3. (part of the top area of admob ad shows up)

 

(3) If y = display.contentHeight - display.screenOriginalY  * 2 , admob shows correctly at the bottom for iPhone 5S, but below the bottom for Galaxy Tab 3. For Galaxy Tab 3, in order to show at the exact bottom, I found y = display.contentHeight - display.screenOriginalY  * 2 - 63  would do. (I don’t know how to get this number, 63. I started with 50 & 66, and adjusted one pixel at at a time to get 63.) BTW, display.screenOriginalY for Galaxy Tab 3 is -16.

 

The conclusions:

 

(1) For iAd, it still looks like it’s “bottom-aligning”, is this final?

 

(2) For admob, the y value behaves differently than iAd, why is that? is this intended behavior? What’s the rule?

 

(3) For admob, iOS device & Android device seem to behave differently? How to correctly calculate the y value to place admob at the exact bottom for both iOS & Android devices?

 

Please someone shed some light on this. I am about to release a new version with iAd & admob before iTunes closes for the holidays. It’s a total mess right now.    :unsure:  Thanks.