Titanium Community Questions & Answer Archive

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

No 'Swipe' on TableView within View?

Got a fair bit of Titanium experience under my belt, but can't seem to figure out the 'swipe' event.

To replicate:
Create a new project (the tab base code), point one of the tab windows at a .js file, and stick a tableView in there. No matter how I try to hack it, I can't get it to pick up a 'swipe' event (though click works fine).

Any ideas? I'm wanting to swipe to navigate the data being viewed (moving to the next/previous day on a calendar view).

— asked July 23rd 2010 by Andy Smith
  • iphone
  • swipe
  • tableview
0 Comments

7 Answers

  • Yeah, it seems the tableview sees the swipe only in edit mode.
    You could register touchstart and touchend events and detect if the difference for x property is bigger than N pixels - we have swipe.

    If is smaller than few pixels we have click :)

    — answered July 23rd 2010 by Dan Tamas
    permalink
    1 Comment
    • Sadly, touchstart/touchmove/touchend don't seem to fire either!
      Get the feeling this is either a major bug, or I'm being a major idiot.

      Can anyone clarify? :D

      ~A

      — commented July 23rd 2010 by Andy Smith
  • Do you want just the general swipe action, or the swipe to delete action?

    If its the latter, then make sure you have editable:true in your createTableView()

    — answered July 23rd 2010 by Chris Johnson
    permalink
    2 Comments
    • Cheers for the answer - I'm not after swipe to delete.

      I'm creating a 'to-do' list view for a single day, and want the user to be able to swipe left/right to navigate to the previous/next day's list.

      I just can't seem to get the swipe event to fire!

      ~A

      — commented July 23rd 2010 by Andy Smith
    • Has anyone figured this out? I'm on 1.5.1 and on Android - can't get the swipe event to fire on a TableView…

      — commented December 31st 2010 by Takahito Torimoto
  • Add touchstart to the table.

    The issue is that if you have a custom row and click on an element( label by example ) you don't get the x coordinate.

    can you show me how your row looks like?

    — answered July 23rd 2010 by Dan Tamas
    permalink
    3 Comments
    • It's not even a custom row - though it does have some custom data attached:

      var row = Titanium.UI.createTableViewRow({
          eventid:calendarevents[i].id,
          title: hours + ':' + minutes + ' - ' + calendarevents[i].title,
          eventtitle:calendarevents[i].title, 
          eventdescription: calendarevents[i].description,
          eventstarttime: hours + ':' + minutes,
          eventendtime: endtimehours + ':' + endtimeminutes,
          eventstarttimestamp:calendarevents[i].starttime,
          eventendtimestamp:calendarevents[i].endtime
      });
      
      data.push(row);
      

      Draws fine, click events are fine, data is passed fine - just no swipe or touch events fire!

      ~A

      — commented July 23rd 2010 by Andy Smith
    • Additional discovery: the touch events DO work, but only on rows that have data in them.

      Hmm, if the events are only on populated rows, I may have to rethink this as I need the swipe event to work even when it's an empty tableview.

      I shall wrap the whole thing in a view and attach the swipe event to that. Let's see what happens…

      — commented July 23rd 2010 by Andy Smith
    • No go on the View-based solution. Same problems, and no swipe!

      Looks like I'll have to give up on this functionality unless someone can show me otherwise!

      — commented July 23rd 2010 by Andy Smith
  • wait a second, you have empty rows? mmm

    do something else:

    create a custom row like this( hope is clear )

    tablerow->wrap_view( width:100%, height: your_row_height)->label
    

    if you have data set the label else let only the wrap_view

    add touchstart/end to wrap_view

    it works?

    — answered July 23rd 2010 by Dan Tamas
    permalink
    1 Comment
    • Sorry, by 'empty rows' I meant that the table view takes the whole screen, but there isn't enough data to fill it, so it renders some 'empty' rows. I didn't mean I was adding empty rows to it!

      — commented July 23rd 2010 by Andy Smith
  • How many visible rows are in an empty table? 9 ?
    Why not create "fake" rows with empty text( or spaces ) until you reach the minimum numbers?

    Would this work?

    — answered July 23rd 2010 by Dan Tamas
    permalink
    0 Comments
  • Did you get this resolved? Ive come across the same bug, need a fix for it to complete my app

    — answered July 29th 2010 by Chris Johnson
    permalink
    0 Comments
  • Did you get this resolved? Ive come across the same bug, need a fix for it to complete my app

    — answered July 29th 2010 by Chris Johnson
    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.