【问题标题】:Multiline text in tableview row in TitaniumTitanium中tableview行中的多行文本
【发布时间】:2013-01-10 11:15:16
【问题描述】:

我正在 Titanium 中开发基于 tableView 的应用程序。 我需要在我的表格视图行中显示长文本内容。

当我这样做时,我的行看起来像:

这是我用来创建表格视图行的代码。

var row = Ti.UI.createTableViewRow({
        backgroundColor : '#F0F0F0',
        color           : 'black',
        font            : { fontSize:10 ,fontWeight:'bold',fontFamily:'Arial'},
        height          :'80',
        title           : firstRowContent
     });

我的问题是我需要将文本包装在我的表格视图行中,并且需要在多行中显示它。

在 iOS 中有 lineBreakModenumberOfLines 属性。而且我可以轻松做到。

钛有什么办法吗?我搜索了很多,但每个人都说在文本之间添加一个“\n”或添加多个标签。

这些是我提到的链接:

  1. multiline label
  2. multiline text textwrap linebreaks in buttons and table view items
  3. Display resultset (text) within a label, multiline
  4. Multiline Label?
  5. mutiline tablerow from database

【问题讨论】:

    标签: ios uitableview titanium titanium-mobile appcelerator-mobile


    【解决方案1】:

    您需要在行中放置一个标签对象。可以创建标签以包裹文本。

    搜索答案时,搜索complex tableviewrow appcelerator

    【讨论】:

    • 我已经通过添加标签解决了这个问题。感谢您的回答。
    【解决方案2】:

    以下内容适合我。 Titanium 的默认标签行为是对其进行换行。行视图的“标题”属性是单行的。

    var win = Ti.UI.createWindow({
        backgroundColor: '#fff'
    });
    var row = Ti.UI.createTableViewRow();
    row.add(Ti.UI.createLabel({
        text: 'Gosh golly, this is a label. Cool, huh?',
        color: '#000', font: { fontSize: 32 }
    }));
    win.add(Ti.UI.createTableView({
        data: [ row ]
    }));
    win.open();
    

    如果您要在行上设置一个高度以使折线不适合,那么它将为您设置为椭圆。

    row.add(Ti.UI.createLabel({
        text: 'Gosh golly, this is a label. Cool, huh?',
        color: '#000', font: { fontSize: 32 },
        height: 40
    }));
    

    但默认情况下,它会根据您提供的内容调整大小。

    【讨论】:

    • 我已经通过添加标签解决了这个问题。谢谢你的回答。
    【解决方案3】:

    我通过添加标签作为 tableview 行的子视图来解决此问题。

     var firstRow = Ti.UI.createTableViewRow({
            backgroundColor : '#F0F0F0',
            color           : '#555555',
            font            : { fontSize:10 ,fontFamily:'Arial'},
            height          :'auto',
           // title         : firstRowContent,
            horizontalWrap  : 'true',
            selectionStyle  : Ti.UI.iPhone.TableViewCellSelectionStyle.NONE
         });
          var firstLabel = Ti.UI.createLabel({
            text            : 'Midhun Says: Hi, How are you ? We are currently waiting for you ...',
            height          : 'auto',
            right           : '10',
            top             : '7',
            left            : '10',
            color           : '#555555',
            font            : { fontSize:15 ,fontFamily:'Arial'},
         });
    
    firstRow.add(firstLabel);
    

    不管怎样,谢谢大家的帮助...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-20
      • 2020-08-20
      • 2018-12-25
      • 2017-03-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多