触摸 GADBannerView 子视图时 UIScrollView 不滚动

UIScrollView doesn#39;t scroll when touching GADBannerView subview(触摸 GADBannerView 子视图时 UIScrollView 不滚动)

本文介绍了触摸 GADBannerView 子视图时 UIScrollView 不滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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.

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.

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.

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

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

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.

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

Thanks!

解决方案

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.

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.

这篇关于触摸 GADBannerView 子视图时 UIScrollView 不滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:触摸 GADBannerView 子视图时 UIScrollView 不滚动

基础教程推荐