canDisplayBannerAds Issue when Starting in Landscape Mode

随声附和 提交于 2019-12-12 00:26:21

问题


I have enabled banner ads via self.canDisplayBannerAds = YES; on a modal view within my app. The banner shows at the bottom of the screen just below a toolbar. When starting the app in portrait mode and moving to this VC, the ads look correct. When on this VC if I rotate to landscape mode the view also resizes correctly and all is well. However, if I start the app in landscape mode and then navigate to this VC, the toolbar is not displayed correctly. The buttons are forced down partially off the screen even before the iAD starts. Once the iAD starts the bar does move up; however, the buttons are still incorrectly located.

If I disable ads and start the app in landscape mode the toolbar is fine so I am sure this is due to the ad. I am thinking it is screwed up on the orientation since this command is called in ViewDidLoad but I cannot call it afterwards or the entire placement gets totally screwed up.

How can I get the iAd to place itself correctly when starting in landscape mode?


回答1:


So to fix this issue I had to add another constraint on the y-axis. I had a constraint prior to the bottom of the view but by adding another y constraint at the top of the toolbar (its nearest neighbor is a scrollview) the issue was resolved. Not sure why it worked without that constraint in all other scenarios, but this did resolve the issue.



来源:https://stackoverflow.com/questions/24314129/candisplaybannerads-issue-when-starting-in-landscape-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!