Swipe Event
Ok so has anyone found a fix to this? I am trying to achieve a menu that is only visible when swiped on a table row. So I have tried the following
table.addEventListener('swipe', function(e)
{
// do stuff
});
My table is added to a Titanium.UI.createView() item. I can not seem to get the swipe function to work. If anyone as got a working version I would love to see.
I am using Ti SDK 1.3.2 and iPhone SDK 3.1
2 Answers
-
If you add a 'swipe' listener to the entire table (as your code shows), it will fire indiscriminately for a swipe anywhere in the table. What you asking, though, is to fire an event when the user swipes on the row. This is what you need instead:
var tableView = Ti.UI.createTableView({ }); var numRows = 10; var data = []; for (var i=0; i<numRows; i++) { var row = Ti.UI.createTableViewRow({ //*** Add whatever properties you need }); row.addEventListener('swipe' function(evt) { //*** Handle swipe event }); data.push(row); } tableView.setData(data);
-
As far as I know swipe does not work on tables. You might try to register the touchstart and touchend x,y coords and if there is a big difference on y to trigger your function.
The problem become harder when the row is custom, but I think is doable.
to un-duplicate :)