1

我们正在将第三方优惠墙集成到我们的 iOS phonegap 应用程序中。

当我们展示 offerwall 时,它会被添加到标准 phonegap viewcontroller 并显示在我们的 webview 顶部。

它的问题是人们可以将视图拖到整个地方,而不是仅仅在原地上下滚动。效果如下图所示:

视图被拖出屏幕

我们想要实现的是能够锚定这个视图,这样它就不能在应用程序周围拖动,只能垂直滚动。

在集成代码中,我们可以访问优惠墙的 UIView 和主应用程序的 ViewController。

offerwall 是作为库提供的,因此我无法访问它的任何代码,只能处理返回的 UIView 和我将其添加到的 UIViewController。其他应用程序已经设法在没有水平滚动的情况下实现视图

我们正在寻找适用于 UIView 或 ViewController 的代码来防止这种情况发生。

谢谢

4

2 回答 2

1

offerwall 视图可能包含一个UIScrollView保存实际内容的视图。您可以尝试遍历所有子视图并在它找到的第一个滚动视图上关闭滚动:

    for (UIView *view in offerwall.subviews) {
        if ([view isKindOfClass:[UIScrollView class]]) {
            UIScrollView *scrollView = (UIScrollView*)view;

            scrollView.scrollEnabled = NO;
            return;
        }
    }

这绝对是 hacky,但如果您无法从他们的代码中访问任何其他内容,这可能是您唯一的选择。

于 2013-04-11T22:47:05.273 回答
0

In the end the solution was quite simple. Turns out the offerwall was a UIWebView and in testing mode the offerwall page was rendering some elements that were overflowing the page hence the horizontal scrolling. In production mode the problem goes away

于 2013-04-12T08:44:41.850 回答