Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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

— asked July 29th 2010 by Chris Johnson
  • iphone
  • sdk
  • swipe
  • tableview
0 Comments

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);
    
    — answered June 10th 2011 by Mark Pemburn
    permalink
    0 Comments
  • 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 :)

    — answered July 29th 2010 by Dan Tamas
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.