如何在滚动条上添加 UIView 但视图应保持静止?
iPhone Interface Builder 问题:有人知道如何在 ScrollView 上添加一个小的 UIView 但图像应该保持静止吗?基本上我已经在滚动上有一个完整的图像 (320 x 480),因此图像可以滚动,但现在我需要在其顶部添加一个 AdMob 视图 (320 x 48)。问题是在我构建并运行之后,广告也会滚动。怎么让它保持静止? 谢谢你!
iPhone Interface Builder question: Does anybody know how to add a small UIView over a ScrollView yet the image should stay still? Basically I already have a full image (320 x 480) over the Scroll, so the image scrolls, but now I need to add a AdMob View (320 x 48) on top of them. The problem is after i build and run, the ad scrolls as well. How do you make it stay still?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定这是否是您在代码中完成的方式,但如果您已将 AdMob 视图添加为滚动条的子视图,那么它将滚动。
如果您将其添加为其他地方的子视图(滚动条的超级视图或窗口本身),它不应滚动。
我承认,虽然我通常不使用 Interface Builder,并且通常会以编程方式处理此问题,但我希望这会有所帮助。
Not sure if this is how you've done it in your code, but if you've added the AdMob view as a subview of the scroller, then it will scroll.
It should not scroll if you add it as a subview elsewhere, either the superview of the scroller or the window itself.
I admit though that I generally do not use Interface Builder and would generally handle this programmatically, but I hope this helps.
只需将 AdMob 视图放置在 ScrollView 的同一层次结构级别上,但位于前面。然后,当广告可用时,设置 adMobView.hidden=NO,当广告不可用时,设置 adMobView.hidden=YES。本质上,层次结构是:
当然,当广告可见时,您将无法点击它进行滚动,除非您将其子类化以将点击传递到层次结构中的下一级。但由于广告 (48) 相对于整个滚动视图 (480) 的尺寸减小,您可能不会遇到此问题。
Just place the AdMob view at the same hierarchical level of the ScrollView but being in front. Then when the Ad is available, set adMobView.hidden=NO, when it is not available set adMobView.hidden=YES. Essentially the hierarchy is:
Of course when the Ad is visible you will not be able to tap on it to scroll, unless you subclass it to pass the tap to next level in hierarchy. But probably you have not this problem thanks to the reduced size of the Ad (48) with respect to the entire scrollView (480).