views:

1126

answers:

1

Hey everyone, I was just wondering if anyone knows how to create a UITableviewCell swipe effect akin to the one in the Tweetie 2.0 app (see video: Tweetie 2.0) or in the Facebook 3.0 app (when pressing the blue "+" next to a status).

What I need to do is to have the cell slide away in response to you swiping it and reveal a background view.

Any help would be appreciated!

+6  A: 

Both Tweetie and Facebook implement their own 'custom' swipe detection. What I mean is that instead of using the standard UITableView hooks for swipes, you override touchesBegan:withEvent:, touchesMoved:withEvent:, et.c in your own subclass of UITableView. You can then start detecting swipes yourself and call whatever methods you want on your UITableViewCell's. (Hint: to get the cell given an UITouch, use the UITableView method indexPathForRowAtPoint:)

There's also a another plus to managing your own swipes: you get a lot more control over how accurate each swipe needs to be.

Thanks, this is very useful. Would you happen to know how to display the background view as well?
Max
You can just draw in the background view yourself when cell is swiped. Actually, you can do anything you like, really, with this approach :)
Thanks for all your help, I think I've got it now.
Max
Wow indexPathForRowAtPoint <3!
Tejaswi Yerukalapudi
Don't do this! Detecting your own gestures is coding suicide. Take a Look at UIGestureRecognizer : http://developer.apple.com/library/ios/#documentation/uikit/reference/UIGestureRecognizer_Class/Reference/Reference.html
Ben