Landscape iAd is showing the portrait graphic in iOS6?

牧云@^-^@ 提交于 2019-12-11 03:48:50

问题


My app runs in the Portrait orientation, but the content inside rotates with the accelerometer. I show an iAd on the bottom of the screen. The iAd changed position as you rotate, but the actual interface does not rotate (shouldAutorotate returns NO, all the rotates are handled in OpenGL). So the iAd is positioned, and then a transform is set to rotate it so it's the correct way up for the user. When the app is in Portrait, it's the portrait ad. When in Landscape, it's the landscape. This has been working perfectly since iAds were first released... til now.

In iOS6, the iAd is still positioned correctly, but no matter what I do, the content is not. It seems like iOS6 decides which type of ad it should show. I think this is to do with the autosizing. But I'm confused about how to stop it. I end up with the portrait graphic being shown in landscape mode... over to one side... and cut off because of the thinner ad space.

Has anyone else seen this behaviour? It's only under iOS6. Does anyone know how to stop the iAd from auto-sizing/content rotating?

Any help would be greatly appreciated.


回答1:


This may be due to autolayout, a new feature of iOS 6. Check the first ("File Inspector") tab of your storyboard and if "Use Autolayout" is ticked, that's probably your issue!

With autolayout enabled, views are based on 'constraints' instead of the simple autosizing parameters previously available. These contraints override most attempted changes to the frame of subviews - and that would therefore explain your problem.

It's possible to continue using autolayout and ensure that your constraints are set correctly, but if you're relying on code to change the position/size of your ad view then I would recommend simply disabling autolayout, which should make your resizing normal again!




回答2:


I imagine you are using a similar method to below for when a banner is loaded?

 - (void)bannerViewDidLoadAd:(ADBannerView *)banner {

       self.bannerView.frame = CGRectZero;
 }

Try changing it to something like this

 - (void)bannerViewDidLoadAd:(ADBannerView *)banner {

       self.bannerView.frame = CGRectMake(0, 0, 480, 32);
 }


来源:https://stackoverflow.com/questions/13020832/landscape-iad-is-showing-the-portrait-graphic-in-ios6

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