Titanium ellipsize property is not working for Label in iOS

120 views Asked by At

In iOS ellipsize property is not working for me. The same code is working for android. I have attached the iOS screenshot for iOS issue below. Please help me to understand If I am missing something.

Thanks in Advance!!!

Ti SDK: v9.0.3GA

var win = Ti.UI.createWindow({
    title: 'Demo App',
    backgroundColor: '#DCDCDC',
    layout: 'vertical'
});

var tableView = Ti.UI.createTableView();
var row = Ti.UI.createTableViewRow({
    height: Ti.UI.SIZE,
    width: Ti.UI.FILL
});


var firstLabel = Ti.UI.createLabel({
    text: 'Hello, This is for testing. I wanted to check Ti Ellipsize property ...',
    height: 'auto',
    right: '10',
    top: '50',
    left: '10',
    color: '#F0F0F0',
    font: { fontSize: 15, fontFamily: 'Arial' },
    //horizontalWrap: true,
    wordWrap: false,
    ellipsize: true,
    maxlines: 1
});

row.add(firstLabel);

tableView.setData([row]);

win.add(tableView);
win.open();

Android and iOS simulator Screenshot

1

There are 1 answers

0
Kamal Kant On BEST ANSWER

I just did research on this above issue and I came to know in iOS its automatically applied ellipsize property to your labels. The only thing we need to take care is height property if possible remove or assigned Ti.UI.SIZE.

I have modified my above code and mentioned here in this post. I write a conditional logic for android device.

var deviceDetect = require('./deviceDetect');
var win = Ti.UI.createWindow({
    title: 'Demo App',
    backgroundColor: '#DCDCDC',
    layout: 'vertical'
});

var tableView = Ti.UI.createTableView();
var row = Ti.UI.createTableViewRow({
    height: Ti.UI.SIZE,
    width: Ti.UI.FILL
});


var firstLabel = Ti.UI.createLabel({
    text: 'Hello, This is for testing. I wanted to check Ti Ellipsize property ...',
    height: Ti.UI.SIZE,
    right: '10',
    top: '50',
    left: '10',
    color: '#F0F0F0',
    font: { fontSize: 15, fontFamily: 'Arial' },
    //wordWrap: false, //remove this deprecated in Ti v8.x
    ellipsize: deviceDetect.isAndroid() ? true : false,
    lines: deviceDetect.isAndroid() ? 1 : undefined
});

row.add(firstLabel);

tableView.setData([row]);

win.add(tableView);
win.open();