Problem
For consistency and parity, we need to decide how we should display numbers by default in the UI across all platforms. For example, the
toString()
method has always been necessary on Android when displaying a Number type that is an integer in a Label, to prevent it displaying as a float. iOS, on the other hand, displays it as an integer.
We should test all UI modules that are able to display text (for example,
AlertDialog
,
TextField
,
OptionDialog
) with an aim of making them consistent.
Test case
The code below returns these results:
* Android displays 324.0
* iOS displays 324
Note that the
Ti.API.info()
statement confirms that
label.text
is a Number type on Android and iOS.
var win = Ti.UI.createWindow({
backgroundColor: 'white',
fullscreen: false
});
var bigNumber = 324;
var label = Ti.UI.createLabel({
backgroundColor:'green',
text: bigNumber,
textAlign: 'center'
});
win.add(label);
win.open();
Ti.API.info('Label.text is type: '+typeof(label.text));
It would be great if we can wrap up one of the last major parity issues in 3.2
Few quick comments. There is no typeof method, it's just an operator. Wrapping parens around it works fine, but it's superfluous. It's like doing
It's better to do typeof label.text instead of typeof(label.txt) As far as the point at hand, I wonder if this is actually a parity bug in our code, or just a difference in V8 and JSCore.
It has been decided that this issue should be closed as “Won’t do.” This issue is out of date with our current supported SDK release (7.5.2.GA as of the date of closure), and out of date with mobile OS versions. If community members feel that the issue is still valid, please create a new ticket. Please reference this closed ticket number, include SDK used, comments, and code that demonstrates/reproduces the issue.