【问题标题】:Titanium webview crashes when adding a row to html table向 html 表添加行时,Titanium webview 崩溃
【发布时间】:2011-10-13 03:32:07
【问题描述】:

我有带有内联 html 的 webview 作为我的窗口的一部分。它包含一个大约 10 行的 html 表。当我尝试向表中再添加 1 行时,应用程序崩溃了。

    webView = Titanium.UI.createWebView({
        scalesPageToFit:false,
        top:0,
        bottom:0
    });

    var html = '<html>'+
    '<body>'+
    '<table width="98%" align="center" border="0" cellspacing="0" cellpadding="0">'+
    '<tr>'+
    '<td align="left" height="25" colspan="2" style="color:#ba2424; font-size:14; font-weight:bold">Use RedAnar To:</td>'+
    '</tr>'+
    '<tr>'+
    '<td width="10%" height="25"><img src="'+sc+'"></td>'+
    '<td width="90%" height="25" style="color:#000; font-size:14; font-weight:bold">Store Card Data</td>'+
    '</tr>'+
    '<tr>'+
    '<td width="10%" height="25"><img src="'+eo+'"></td>'+
    '<td width="90%" height="25" style="color:#000; font-size:14; font-weight:bold">Explore Offers</td>'+
    '</tr>'+
    '<tr>'+
    '<td width="10%" height="25"><img src="'+cl+'"></td>'+
    '<td width="90%" height="25" style="color:#000; font-size:14; font-weight:bold">Capture Loyalty</td>'+
    '</tr>'+
    '<tr>'+
    '<td width="10%" height="25"><img src="'+tp+'"></td>'+
    '<td width="90%" height="25" style="color:#000; font-size:14; font-weight:bold">Track Points</td>'+
    '</tr>'+
    '<tr>'+
    '<td width="10%" height="25"><img src="'+vb+'" valign="absmiddle"></td>'+
    '<td width="90%" height="25" style="color:#000; font-size:14; font-weight:bold">View Balances</td>'+
    '</tr>'+
    '<tr>'+
    '<td align="left" height="25" colspan="2" style="color:#ba2424; font-size:14; font-weight:bold">Card Description</td>'+
    '</tr>'+
    '<tr>'+
    '<td align="left" height="20" colspan="2" style="color:#000; font-size:14; font-weight:normal">'+description+'</td>'+
    '</tr>'+
    '<tr>'+
    '<td align="left" height="25" colspan="2" style="color:#ba2424; font-size:14; font-weight:bold">Highlights</td>'+
    '</tr>'+
    '<tr>'+
    '<td align="left" height="20" colspan="2" style="color:#000; font-size:14; font-weight:normal">'+highlights+'</td>'+
    '</tr>'+
    '</table>'+
    '</body>'+
    '</html>';

    webView.html = html;

如果我尝试在此之后再插入 1 行,应用程序将崩溃。有什么建议吗?

【问题讨论】:

  • 这是适用于 iPhone 还是 Android?

标签: webview titanium


【解决方案1】:

我刚刚测试了您的代码,并且它有效(不过,我将您的变量用作文本,因为我不知道其中的内容)。

我在最后添加了以下行,它也有效:

'</tr>'+
'<tr>'+
'<td align="left" height="20" colspan="2" style="color:#000; font-size:14; font-weight:normal">'+"highlights"+'</td>'+
'</tr>'+

当它不起作用时,你会添加哪一行?当它崩溃时它会给出什么错误?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-28
    • 1970-01-01
    • 1970-01-01
    • 2016-07-14
    • 2023-03-07
    • 2012-03-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多