简体   繁体   English

iPad上的iAd:横向iAd定位不正确

[英]iAd on iPad: Landscape iAd not Oriented Correctly

This is still a relatively new topic so not sure how many people have got to implement iAd on iPad (iOS4.2.1). 这仍然是一个相对较新的话题,因此不确定要在iPad(iOS4.2.1)上实施iAd的人有多少。

But basically, I get the iAd banner to appear in landscape mode (and it appears correctly). 但基本上,我使iAd标语以横向模式显示(并且正确显示)。 The only problem is when I click the "Test Advertisement" it shows the test advertisement in portrait mode. 唯一的问题是,当我单击“测试广告”时,它以纵向模式显示了测试广告。 Ie, the device is still in landscape but the text and iad box itself that says "this confirms that test ads are running correctly" is sideways. 也就是说,该设备仍处于横向状态,但是文字和iad框本身显示“这表明测试广告运行正常”是横向的。

Is this normal? 这正常吗? has anyone else experience this? 有没有其他人经历过? It almost seems like an apple bug but I'm not sure... 几乎看起来像是苹果的虫子,但我不确定...

This happens to me, too. 我也是这样 Apple's test ads on iPhone and iPad are portrait only. 苹果在iPhone iPad上的测试广告仅是纵向的。 Real advertisements probably will support landscape mode. 实际的广告可能支持横向模式。

the ADBannerView's requiredContentSizeIdentifiers is defaulted to have Landscape AND Portrait. 默认情况下,ADBannerView的requiredContentSizeIdentifiers具有“横向”和“纵向”。 If you are using landscape only, you must make a new NSSet with ADBannerContentSizeIdentifierLandscape 如果仅使用横向,则必须使用ADBannerContentSizeIdentifierLandscape新建一个NSSet

iAdView.requiredContentSizeIdentifiers = [NSSet setWithObjects:ADBannerContentSizeIdentifierLandscape, nil];

After doing this, the test ad with show up correctly. 完成此操作后,带有的测试广告会正确显示。

I just had the same issue and in my case it was caused by not setting the rootViewController in the app delegate. 我只是遇到了同样的问题,就我而言,这是由于未在应用程序委托中设置rootViewController引起的。 Instead I had just added the controller's view directly to the window. 相反,我只是将控制器的视图直接添加到窗口中。

This behaviour can be reproduced by making a single change to the BasicBanner example from Apple's iAdSuite. 可以通过对Apple的iAdSuite的BasicBanner示例进行单个更改来重现此行为。

In AppDelegate.m change the line: 在AppDelegate.m中,更改以下行:

self.window.rootViewController = tvc;

to: 至:

[self.window addSubview:tvc.view];

and the advertisement will always appear in portrait. 并且广告将始终以纵向显示。 Change the line back to setting the rootViewController and the ad will rotate appropriately. 将其改回设置rootViewController的位置,广告将适当地旋转。

Setting the rootViewController appears to be necessary for the iAd module to get device orientation notifications. 设置rootViewController似乎是iAd模块获取设备方向通知所必需的。

Along the way I noticed that the ad, or at least the test ad, only responds to the device orientation and does not respect the controller's interfaceOrientation at the time that the ad is invoked. 在此过程中,我注意到广告或至少测试广告仅响应设备方向,并且在调用广告时不遵守控制器的interfaceOrientation。 If you run BasicBanner without the above mistake and with device laying flat and the app in landscape mode, the ad will appear in portrait and will not reorient to landscape until you tip up the device. 如果您在没有上述错误的情况下运行BasicBanner,并且将设备放平并且应用程序处于横向模式,则广告将以纵向显示,并且在您向上倾斜设备之前不会重新定向为横向。 The simulator behaviour is equally inconsistent. 模拟器的行为同样不一致。

I don't know whether this weakness is particular to just the test ad or all iAd ads. 我不知道这种弱点是否仅适用于测试广告或所有iAd广告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM