的UIScrollView不滚动,当触摸GADBannerView子视图视图、UIScrollView、GADBannerView

2023-09-08 18:49:14 作者:心跳的感觉

我有一个使用谷歌的AdMob广告SDK的项目。我试图显示在主页上的几个广告连同一些其它按钮,其中一些是在屏幕下方

I have a project that uses the Google AdMob Ads SDK. I'm trying to show a few ads on the homepage along with some other buttons, some of which are below the screen.

我用一个UIScrollView,并增加了一些GADBannerViews从DFP内部以及按钮。在广告加载就好了,我可以点击广告和按钮,没有问题。

I've used a UIScrollView and added a few GADBannerViews from DFP inside as well the buttons. The ads load just fine and I can click on the ads and buttons with no problem.

现在的问题是,当我尝试滚动卷轴视图。如果我开始接触上的广告来看,滚动视图不会滚动。如果我开始接触其他地方,像一个按钮或空白,滚动视图滚动正常。看来这个广告在某种程度上走的是触摸事件的控制。

The problem is when I try to scroll the scroll view. If I start touching on the ad view, the scroll view will not scroll. If I start touching anywhere else, like a button or a blank space, the scroll view scrolls properly. It seems that the ad is somehow taking control of the touch events.

我已经试过各种修正,如创建一个透明的UIView上面的广告,没有工作,因为水龙头不会注册。

I've tried all sorts of fixes such as creating a transparent UIView above the ads, which didn't work because the taps would not register.

我试图通过GADBannerView的子视图,但所有的子视图类循环似乎专属于AdMob的或无法访问。 (GADWebView,_UIWebViewScrollView)

I've tried looping through the subviews of the GADBannerView but all the subviews' classes seem proprietary to AdMob or inaccessible. (GADWebView, _UIWebViewScrollView)

我甚至尝试添加广告的UITableView,看它是否会滚动出现,但它并没有擦出火花。

I even tried adding the ad to a UITableView to see if it would scroll there, but it did not work either.

我的视图控制器类是相当大的,所以如果你需要我张贴一些code,我可以创建一个示例应用程序来说明这个问题。一种解决方法现在是创建的HTML广告code UIWebViews,而不是内部使用GADBannerView。我测试过这一点,它的工作原理,但我真的不想失去本地方法的功能。

My view controller class is quite large so if you need me to post some code, I can create a sample app to demonstrate the problem. A workaround for now is to create UIWebViews with the HTML ad code inside instead of using the GADBannerView. I've tested this and it works, but I really don't want to lose the functionality of the native method.

有没有什么办法,如果你开始接触的GADBannerView,让广告继续点击滚动一个UIScrollView?

Is there any way to scroll a UIScrollView if you start touching on the GADBannerView and allow the ad to remain clickable?

谢谢!

推荐答案

不幸的是,没有一个不是办法覆盖滚动手势,但保留了触摸手势的广告。该GADBannerView本身需要控制所有的手势本身。也没有办法以编程方式发送一个点击的GADBannerView要么,所以你不能覆盖触摸行为,无论是。

Unfortunately there is not a not a way to override the scrolling gesture but retain the touch gesture for the ad. The GADBannerView itself needs to control all of the gestures on itself. There is also no way to programmatically send a click to the GADBannerView either, so you can't override the touch behavior either.

我会建议使用的广告,比您的UIScrollView要小很多,所以你不必太担心了滚动广告。

I would recommend using ads that are much smaller than your UIScrollView, so you don't have to worry too much about scrolling over an ad.