如何在滚动条上添加 UIView 但视图应保持静止?

发布于 2024-10-16 15:21:28 字数 189 浏览 1 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

<逆流佳人身旁 2024-10-23 15:21:28

不确定这是否是您在代码中完成的方式,但如果您已将 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.

初心未许 2024-10-23 15:21:28

只需将 AdMob 视图放置在 ScrollView 的同一层次结构级别上,但位于前面。然后,当广告可用时,设置 adMobView.hidden=NO,当广告不可用时,设置 adMobView.hidden=YES。本质上,层次结构是:

RootView -
          |---- UIScrollView
                           |----- any UIView (to be scrolled)
          |---- AdMobView   --> not subview of ScrollView but subview of RootView

当然,当广告可见时,您将无法点击它进行滚动,除非您将其子类化以将点击传递到层次结构中的下一级。但由于广告 (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:

RootView -
          |---- UIScrollView
                           |----- any UIView (to be scrolled)
          |---- AdMobView   --> not subview of ScrollView but subview of RootView

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文