[英]CodenameOne: Webview not scrollable in iOS version of app
我有一个旧的cn1应用程序(使用旧的GUI构建器),该Web组件位于Form的中心(居中于BorderLayout容器,它是Form的主要组件),并且带有Web浏览器组件。 在模拟器以及Android设备上,WebBrowser均可正常显示。 在iOS模拟器中,整个组件显示为黑色矩形,在iPhone(运行iOS 9.1的5s)上,WebBrowser的内容可见但不滚动。
是否需要更改某些特定设置才能使其滚动?
这是我的代码:
WebBrowser web = new WebBrowser() {
@Override
public void onLoad(String url) {
System.out.println("Article body webview loaded");
Component c = getInternal();
if (c instanceof BrowserComponent) {
BrowserComponent b = (BrowserComponent) c;
String text = ((String) m.currentArticleInfo.get("id"));
b.execute("loadArticle('" + text + "')");
}
}
};
((BrowserComponent) web.getInternal()).setNativeScrollingEnabled(true);
((BrowserComponent) web.getInternal()).setScrollVisible(false);
web.setScrollVisible(false);
web.setURL("jar:///article_body.html");
web.setScrollable(true);
web.getAllStyles().setPaddingTop(10);
form.addComponent(BorderLayout.CENTER, web);
我在控制台中看不到任何错误。 网页代码如下所示:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="https://www.example.com/styles/style.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<style>
body::-webkit-scrollbar{
width: 0 !important;
}
#left_side_article #right #the_article #details_info{
font-size: 3.5mm !important;
}
div#the_article{
border: none !important;
}
div#the_article_header{
padding: 0 !important;
}
</style>
</head>
<body style="min-height: 100px">
<div id="left_side_article">
<div id="right">
<div id="the_article">
<div id="details_info" >
</div>
</div>
</div>
</div>
<script>
function loadArticle(content) {
console.log('in load article function, article id: ' + content);
var url = "https://www.example.com/api/article_body_ajax.php";
$.post(url,{"app_code": "myappcode", "id" : content},function(data,status,jqxhr){
$("#details_info").html(data);
$("#details_info img").each(function(){
$(this).attr("src", "https://www.example.com/" + $(this).attr("src"));
$(this).css("height", "auto");
});
});
};
</script>
</body>
</html>
我尝试通过下载应用程序源并使用Safari来检查页面来调试WebView。 Safari意识到应用程序中有一个打开的网页,我可以从Safari的“开发”菜单中选择它,但是“检查”窗口完全是空的-没有任何元素。
这可能与我们对getComponentAt
所做的更改有关,以查看在本周末更新之后是否仍在发生这种情况。 我们在这里讨论了与此相关的一些回归: https : //www.codenameone.com/blog/dont-touch-that-code.html
我只是在这里针对iOS中的滚动问题提交了修复程序。 如果调用setNativeScrollingEnabled(true)
,有一个错误会导致滚动被禁用。 下一个库更新(下星期五)将提供此修复程序。 同时,您可以通过不调用setNativeScrollingEnabled(true)
来解决此问题-因为无论如何默认值都是true
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.