I had a bug introduced into my app with the 1.5.1 release and thought I'd share. I had an image that toggled between two states when clicked. To detect the current state, I previously could read the .image property and compare it to a string like so:
var iview = Ti.UI.createImageView({image:'checked.png'}); if (iview.image == 'checked.png') {Ti.API.info('The image is checked.')};Running that code now gives:
[ERROR] Script Error = invalid method 'toString:' at app.js (line 2).
Apparently the .image property is no longer a string nor does it have a toString method. Not sure if this is a bug or a feature.
In my case, the work-around is to add another property:
var iview = Ti.UI.createImageView({image:'checked.png', is_checked:true}); if (iview.is_checked) {Ti.API.info('The image is checked.')};This has been tested on the iPhone simulator only.
2 Answers
I'm having the same problem. But I cannot use your workaround because I need the actual URL for the string. How to read the image in 1.5.1? When I log Ti.API.info(theImageView.image) it logs the value correctly. But when I compare if ("theURL.jpg" == theImageView.image) it throws the same invalid method toString error.
I have the same issue as well, now using 1.6.1. I try to compare the image string of an image used in a tablerow and I get message = "invalid method 'toString:'"; I really need to be able to look at the current image to see if I need to change it. Any help on this anyone?
Your Answer
Think you can help? Login to answer this question!