Display resultset (text) within a label, multiline
I´m actually trying to fetch some data from the underlying sqlite database on iPhone platform. This does work pretty well, indeed.
This works for simple text only. Multiline (with \n and \r) does not.
Does someone know how to solve this, how to make text coming from database come out as multi-line text?
Any help is much appreciated!
5 Answers
-
did u set this?
label.height = 'auto'
-
Found an answer to my problem.
Though, it´s a quite simple (and dirty!) … call it a hack :)
function evalStrings(string) { eval('result="'+string+'"'); return result; } text = evalStrings(row.fieldByName('simple_text'));
This code should treat some \n and stuff as if you´d write them by hand.
They come out as expected…Please let me know if you have solved this differently.
Cheers. -
Actually, the correct answer is:
text = row.fieldByName('simple_text').replace(/\n/g, "\n");
-
Yes, I did.
My code as follows:var label = Titanium.UI.createLabel({ text:row.fieldByName('text'), height:'auto', width:'auto', highlightedColor: '#fff', top: 10, bottom: 10, left: 10, right: 10, font : { fontSize : 12 } });
-
Any output coming from database seems to be escaped, so that any newlines and carriage returns do not work.
Does someone know a way to solve this, to make newlines work?