Facebook 弹出窗口在 WebView 中不可滚动 - React native

Facebook pop up not scrollable in WebView - React native

提问人:Federico 提问时间:12/19/2020 最后编辑:Federico 更新时间:12/31/2020 访问量:594

问:

我的应用程序有一个 WebView,在 Android 和 iOS 中运行良好,但在某些情况下,会显示以下要求输入 cookie 的 Facebook 弹出窗口,并且无法向下滚动。然后整个 Web 视图不可用。

enter image description here

代码非常简单:

<WebView
  source={{
    uri: url
  }}/>

我怎样才能让它也可滚动? 谢谢!

iPhone React-Native Facebook WebView

评论

0赞 Shahnawaz Hossan 12/19/2020
它是否发生在 Facebook URL 上,或者没有任何东西可以滚动?webview
0赞 Federico 12/19/2020
@ShahnawazHossan 使用我的 Android 和 iOS 模拟器,即使弹出窗口出现也很好,因为它完全适合屏幕。当我尝试使用手机时,弹出窗口出现,但太大了,需要滚动,但我不能。我想让它始终可滚动

答:

0赞 Florin Dobre 12/25/2020 #1

一个可能的解决方案是将 webview 包含在 ScrollView 中

<ScrollView contentContainerStyle={{ flexGrow: 1 }}>
  <WebView
    source={{
      uri: url
    }}/>
</ScrollView>

其他可能的解决方案可能是使用:

https://github.com/iou90/react-native-autoheight-webview#readme

注意:如果 webview 已经包含在检查中,是否设置一些或一些会使模式可滚动到最后。ScrollViewbottomPaddingcontentInset

0赞 John 12/31/2020 #2

分辨率太小,无法显示整个弹出窗口。

您可以使用以下方法进行缩小:

webview.setInitialScale(1);
webview.getSettings().setLoadWithOverviewMode(true); 
webview.getSettings().setUseWideViewPort(true);

或者,您可以编辑网页本身以使用页面的视口元缩小,使用 CSS 缩小弹出窗口,或者通过将元素的 css 设置为以下元素来向该特定元素添加滚动条:

#target{
max-height:100%;
overflow:scroll;
}