[TIMOB-1103] Setting a button image dynamically
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-10-28T12:36:52.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Backlog |
Components | iOS |
Labels | button, defect, dynamic, image, ios, iphone |
Reporter | ctredway |
Assignee | Reggie Seagraves |
Created | 2011-04-15T02:44:05.000+0000 |
Updated | 2011-10-28T12:36:52.000+0000 |
Description
A customer has been trying to set either the image or the backgroundImage of a button with an image downloaded from a site. The following code shows this bug.
var win = Ti.UI.currentWindow;
var imageView = Titanium.UI.createImageView({
backgroundColor: 'blue',
top:10,
left:10,
width: 125,
height: 89
}); win.add(imageView);
var photoButton = Ti.UI.createButton({
title: 'Click me',
top: 135,
left: 10,
width: 125,
height: 89,
backgroundColor:'blue',
backgroundImage: 'blah'
}); win.add(photoButton);
photoButton.addEventListener('click', function()
{
imageView.backgroundColor = photoButton.backgroundColor = 'red';
c = Titanium.Network.createHTTPClient();
c.onload = function() {
var f = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,'photo.jpg');
Ti.API.info('Writing to:'+f);
f.write(this.responseData);
imageView.backgroundColor = photoButton.backgroundColor = 'green';
//imageView.image = f;
photoButton.backgroundImage = f;
//imageView.image = photoButton.image = 'KS_nav_views.png'; // !!! QUESTION: why does cause a crash?
};
c.ondatastream = function(e) {
ind.value = e.progress ;
Ti.API.info('ONDATASTREAM2 - PROGRESS: ' + e.progress);
};
c.open('GET', 'http://www.appcelerator.com/wp-content/uploads/2009/06/titanium_desk.png');
c.send();
});
Bug is not valid, does not reproduce in: TiMOB sdk version: 1.8.0.v20111027152620 Studio version: 1.0.6.201110251616 OS version: Mac OS X Lion Devices tested on: iphone emulator, iphone 5.0, ipad2 4.3.5