简体   繁体   English

iAd无法在iPhone中横向使用

[英]iAd not working in iPhone in landscape

I have an app that only runs on iPhone in landscape. 我有一个只能在横向iPhone上运行的应用程序。 I have implemented iAd to put a banner across the bottom of the screen. 我已经实施了iAd,将横幅广告放置在屏幕底部。 This worked great when compiled in Xcode 4 but now in Xcode 5 there is a problem. 在Xcode 4中编译时,效果很好,但现在在Xcode 5中出现了问题。 When a user tapped the ad in the old version, the full size ad would load in portrait. 当用户点击旧版本的广告时,完整尺寸的广告将以纵向加载。 But now when a user taps an ad, it loads the ad but only the top half of the screen has the ad - the bottom remains blank. 但是现在,当用户点击广告时,它会加载广告,但只有屏幕的上半部分显示广告-底部仍然为空白。 It work correctly in the simulator and on test devices using the "test" ads, but now that the app is live it is broken. 它可以在模拟器和使用“测试”广告的测试设备上正常运行,但由于该应用程序已上线,因此它已损坏。

Everything works perfectly on iPad, which is not restricted to landscape only. 一切都可以在iPad上完美运行,而不仅限于风景。 I have double checked my code and everything is just as the documentation states. 我仔细检查了我的代码,一切都与文档中所述的一样。 Apple has been less than helpful with this. 苹果对此没有帮助。 Any thoughts? 有什么想法吗?

在此处输入图片说明

Update: I found 2 more pieces to the puzzle. 更新:我发现了另外2个难题。 This only happens with iOS 8. When the user taps the banner ad, I get a "Unable to simultaneously satisfy constraints" error with the following: 这仅在iOS 8上发生。当用户点击横幅广告时,出现“无法同时满足约束”错误,并显示以下内容:

"<NSLayoutConstraint:0x7c948310 H:[UIView:0x7c947e80(219)]>",
"<NSLayoutConstraint:0x7c94edf0 H:[UILabel:0x7c94ecb0'Elapsed\n0:00'(62)]>",
"<NSLayoutConstraint:0x7c94f180 H:[UIView:0x7c94a430]-(0)-[UILabel:0x7c94ecb0'Elapsed\n0:00']>",
"<NSLayoutConstraint:0x7c94f210 UIView:0x7c94a430.width == UIView:0x7c94a320.width>",
"<NSLayoutConstraint:0x7c94f270 H:|-(0)-[UIView:0x7c94a430]   (Names: '|':UIView:0x7c9479e0 )>",
"<NSLayoutConstraint:0x7c94f2d0 H:[UILabel:0x7c94ecb0'Elapsed\n0:00']-(-1)-[UIView:0x7c94a320]>",
"<NSLayoutConstraint:0x7c94f390 H:[UIView:0x7c94a320]-(1)-[UIView:0x7c947e80]>",
"<NSLayoutConstraint:0x7c94f3f0 UIView:0x7c9479e0.centerX == UIView:0x7c947e80.centerX>",
"<NSLayoutConstraint:0x7c9504b0 H:|-(0)-[UIView:0x7c9479e0]   (Names: '|':UIView:0x7c94f920 )>",
"<NSLayoutConstraint:0x7c9504e0 H:[UIView:0x7c9479e0]-(0)-|   (Names: '|':UIView:0x7c94f920 )>",
"<NSLayoutConstraint:0x7c971e90 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7c94f920(320)]>"

"Will attempt to recover by breaking constraint "
"<NSLayoutConstraint:0x7c948310 H:[UIView:0x7c947e80(219)]>"

And, the status bar is now covered by my view, whereas in ios7 it is shown. 而且,状态栏现在已被我的视图覆盖,而在ios7中显示了它。 I built the storyboard layout originally for ios7 so something has changed. 我最初为ios7构建了分镜脚本布局,所以发生了一些变化。 I don't really care (actually prefer) not having the status bar appear, but I can't figure out how to debug those constraints. 我并不在乎(实际上更喜欢)不显示状态栏,但是我不知道如何调试这些约束。

Are you using Storyboards—could there be something there affecting the rotation and sizing? 您是否正在使用情节提要-那里是否有某些东西会影响旋转和调整大小? I recommend making a new project with a single blank view controller set up landscape as yours is and trying to reproduce the issue there. 我建议使用一个空白视图控制器创建一个新项目,并按照您的实际情况设置景观,并尝试在此处重现该问题。

Some things that could be affecting this are: 可能会影响此的一些因素是:

Often I find that going through the steps to recreate a bug reveals errors, lets me see differences between a working version and mine, and ultimately correct the problem. 通常,我发现执行重新创建错误的步骤会发现错误,使我看到工作版本与我的版本之间的差异,并最终纠正了问题。


I find it easiest to compare these against the ones in a Storyboard. 我发现将它们与情节提要中的内容进行比较是最容易的。 For deciphering them like this refer to the visual format language . 要像这样解密它们, 请参考视觉格式语言

It looks like the constraint ensuring a specific view is horizontally 219 equal to its superview is being broken. 看起来确保特定视图在水平方向上等于其超级视图的约束219被打破。 Check your storyboard for any auto layout warnings or errors, I have found it immensely helpful in Xcode 6. 检查您的情节提要中是否有任何自动布局警告或错误,我发现它在Xcode 6中非常有用。

You have several constraints, if you can remove some while debugging that can make things much simpler. 如果您可以在调试时删除一些约束,这会使事情变得简单得多,则有几个约束。 Lastly if your subviews all reference each other that may make satisfying the constraints more difficult, if that is the case referencing the superview may help prevent conflicts. 最后,如果所有子视图都相互引用,这可能会使满足约束变得更加困难,如果是这种情况,则引用超级视图可能有助于防止冲突。

Here are some references for debugging: 以下是一些调试参考:

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

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