Skip to content

Instantly share code, notes, and snippets.

@egomez99
Created October 20, 2012 03:25
Show Gist options
  • Save egomez99/3921905 to your computer and use it in GitHub Desktop.
Save egomez99/3921905 to your computer and use it in GitHub Desktop.
Convert to BLOB
var win = Ti.UI.createWindow({
backgroundColor: 'white'
});
var data = [];
// populate array with rows
for (var i = 0; i < 40; i++)
{
var row = createRow(i);
data.push(row);
}
var tableView = Ti.UI.createTableView({
data: data
});
win.add(tableView);
win.open();
// function used to set up how you want the row to look like
function createView(i)
{
var view = Ti.UI.createView({
width: 320,
height: 30,
});
var description = Ti.UI.createLabel({
text: 'This is description number: ' + i,
top: 0,
left: 50,
width: Ti.UI.SIZE,
height: Ti.UI.SIZE,
});
var imageView = Ti.UI.createImageView({
image: 'KS_nav_ui.png',
top: 0,
left: 5,
width: Ti.UI.SIZE,
height: Ti.UI.SIZE
});
view.add(description);
view.add(imageView);
return view;
}
// function used to actually return a row object
function createRow(i)
{
var row = Ti.UI.createTableViewRow();
// get the view we want
var view = createView(i);
// create an empty imageView that will hold the 'screenshot' of the view
var imageView = Ti.UI.createImageView();
// convert the view to a blob and assign it to the imageView
imageView.image = convertToBlob(view);
// add the imageView to the row
row.add(imageView);
return row;
}
// function used to convert a view to blob and return it
function convertToBlob(view)
{
return view.toImage();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment